Ends all tags up to $curIndent level
@param $fileHandle The file handle to write to
@param $curIndent The depth of the node in the tree
547143
protected function endTags($fileHandle, $curIndent) {
    // get document definition
    $docIndent = $this->getRequestValue('docIndent');
    $docLinebreak = $this->getRequestValue('docLinebreak');
    $cacheSection = $this->getRequestValue('cacheSection');

    // get document state from cache
    $lastIndent = $this->cache->get($cacheSection, self::CACHE_KEY_LAST_INDENT);
    $tagsToClose = $this->cache->get($cacheSection, self::CACHE_KEY_TAGS_TO_CLOSE);

    // write last opened and not closed tags
    if ($curIndent < $lastIndent) {
      for ($i=$lastIndent-$curIndent; $i>0; $i--) {
        $closeTag = array_shift($tagsToClose);
        if ($closeTag) {
          $this->fileUtil->fputsUnicode($fileHandle, str_repeat($docIndent, $closeTag["indent"]).'</'.$closeTag["name"].'>'.$docLinebreak);
        }
      }
    }

    // update document state in cache
    $this->cache->put($cacheSection, self::CACHE_KEY_LAST_INDENT, $lastIndent);
    $this->cache->put($cacheSection, self::CACHE_KEY_TAGS_TO_CLOSE, $tagsToClose);
  }
1095635
@Override
  void visitEnclosingElement(Tokenizer.Token value) throws IOException {
    printIndents();
    write("<" + value.getEditsElement().toString() + ">\n");
    tagQ.push(value.getEditsElement());
    depthCounter.incLevel();
  }
909761
function processSubtree( $element, &$lastHandlerResult )
    {
        $ret = null;
        $tmp = null;

        // Call "Init handler"
        $this->callOutputHandler( 'initHandler', $element, $tmp );

        $debug = eZDebugSetting::isConditionTrue( 'kernel-datatype-ezxmltext', eZDebug::LEVEL_DEBUG );

        // Process children
        if ( $element->hasChildNodes() )
        {
            // Make another copy of children to save primary structure
            $childNodes = $element->childNodes;
            $childrenCount = $childNodes->length;

            // we can not loop directly over the childNodes property, because this will change while we are working on it's parent's children
            $children = array();
            foreach ( $childNodes as $childNode )
            {
                $children[] = $childNode;
            }

            $lastResult = null;
            $newElements = array();
            foreach ( $children as $child )
            {
                if ( $debug )
                {
                    eZDebug::writeDebug( 'processing children, current child: ' . $child->nodeName, eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext', __METHOD__ ) );
                }

                $childReturn = $this->processSubtree( $child, $lastResult );

                unset( $lastResult );
                if ( isset( $childReturn['result'] ) )
                {
                    if ( $debug )
                    {
                        eZDebug::writeDebug( 'return result is set for child ' . $child->nodeName, eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext', __METHOD__ ) );
                    }

                    $lastResult = $childReturn['result'];
                }

                if ( isset( $childReturn['new_elements'] ) )
                {
                    $newElements = array_merge( $newElements, $childReturn['new_elements'] );
                }

                if ( $this->QuitProcess )
                {
                    return $ret;
                }
            }

            if ( $debug )
            {
                eZDebug::writeDebug( $this->Document->saveXML(),
                                     eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                                  'XML before processNewElements for element ' . $element->nodeName ) );
            }

            // process elements created in children handlers
            $this->processNewElements( $newElements );

            if ( $debug )
            {
                eZDebug::writeDebug( $this->Document->saveXML(),
                                     eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                                  'XML after processNewElements for element ' . $element->nodeName ) );
            }
        }

        // Call "Structure handler"
        if ( $debug )
        {
            eZDebug::writeDebug( $this->Document->saveXML(),
                                 eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                              'XML before callOutputHandler structHandler for element ' . $element->nodeName ) );
        }

        $ret = $this->callOutputHandler( 'structHandler', $element, $lastHandlerResult );

        if ( $debug )
        {
            eZDebug::writeDebug( $this->Document->saveXML(),
                                 eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                              'XML after callOutputHandler structHandler for element ' . $element->nodeName ) );
            eZDebug::writeDebug( $ret,
                                 eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                              'return value of callOutputHandler structHandler for element ' . $element->nodeName ) );
        }

        // Process by schema (check if element is allowed to exist)
        if ( !$this->processBySchemaPresence( $element ) )
        {
            if ( $debug )
            {
                eZDebug::writeDebug( $this->Document->saveXML(),
                                     eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                                  'XML after failed processBySchemaPresence for element ' . $element->nodeName ) );
            }
            return $ret;
        }

        if ( $debug )
        {
            eZDebug::writeDebug( $this->Document->saveXML(),
                                 eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                              'XML after processBySchemaPresence for element ' . $element->nodeName ) );
        }

        // Process by schema (check place in the tree)
        if ( !$this->processBySchemaTree( $element ) )
        {
            if ( $debug )
            {
                eZDebug::writeDebug( $this->Document->saveXML(),
                                     eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                                  'XML after failed processBySchemaTree for element ' . $element->nodeName ) );
            }
            return $ret;
        }

        if ( $debug )
        {
            eZDebug::writeDebug( $this->Document->saveXML(),
                                 eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext',
                                                              'XML after processBySchemaTree for element ' . $element->nodeName ) );
        }


        $tmp = null;
        // Call "Publish handler"
        $this->callOutputHandler( 'publishHandler', $element, $tmp );

        // Process attributes according to the schema
        if ( $element->hasAttributes() )
        {
            if ( !$this->XMLSchema->hasAttributes( $element ) )
            {
                eZXMLInputParser::removeAllAttributes( $element );
            }
            else
            {
                $this->processAttributesBySchema( $element );
            }
        }
        return $ret;
    }
404257
def close(self, filehandle):
        """"""
        with self.lock:
            if filehandle in self.files:
                self.files[filehandle] -= 1
                # trim the file cache
                index = 0
                size = len(self.past)
                while size > self.size and index < size:
                    filehandle = self.past[index]
                    if self.files[filehandle] == 0:
                        filehandle.close()
                        del self.files[filehandle]
                        del self.past[index]
                        size -= 1
                    else:
                        index += 1
552908
public void close() throws IOException {
		// close last tag, if present
		if(lastChildNode!=null) {
			lastChildNode.close();
			lastChildNode = null;
		}
		writer.write("\n");
		writer.flush();
		isOpen = false;
	}
718808
private void formatNodeTo(Formatter f, int level, RadixTreeNode<T> node) {
        for (int i = 0; i < level; i++) {
            f.format(" ");
        }
        f.format("|");
        for (int i = 0; i < level; i++) {
        	f.format("-");
        }

        if (node.isReal() == true)
        	f.format("%s[%s]*%n", node.getKey(),  node.getValue());
        else
        	f.format("%s%n", node.getKey());

        for (RadixTreeNode<T> child : node.getChildern()) {
        	formatNodeTo(f, level + 1, child);
        }		
	}
488901
public void endElement(String namespaceUri,
                           String localName,
                           String qualifiedName)
            throws SAXException {
        currentElement = null;
        currentDepth--;
        String indentation = indent(-1);
        String closingElement = "</" + getName(localName, qualifiedName) + ">";
        write(currentlyInLeafElement ? closingElement : nl + indentation + closingElement);
        currentlyInLeafElement = false;
        this.currentElement = null;
        if (frozenArtifactResolver.artifactInheritsVersionFromParent() &&
            ARTIFACT_ID.equals(qualifiedName) &&
            currentDepth == 1) {
            logger.info("[Freezehandler]: Artifact version " + frozenArtifactResolver.artifactFrozenVersion());
            write(nl + indentation + "<" + VERSION + ">" + frozenArtifactResolver.artifactFrozenVersion() + "</" + VERSION + ">");
        }
        switch (qualifiedName) {
            case GROUP_ID:
            case ARTIFACT_ID:
            case PACKAGING:
            case RELATIVE_PATH:
            case "":
                break;
            case VERSION:
            default:
                this.currentGroupIdArtifactIdVersion = new GroupIdArtifactIdVersion();
        }
    }
747535
protected function processTokenWithinScope(File $phpcsFile, $stackPointer, $currScope)
    {
        $methodName = $phpcsFile->getDeclarationName($stackPointer);
        if ($methodName === null)
        {
            // Ignore closures.
            return;
        }

        // Ignore magic methods.
        $magicPart = strtolower(substr($methodName, 2));
        if (isset($this->magicMethods[$magicPart]) === true
            || isset($this->methodsDoubleUnderscore[$magicPart]) === true
        )
        {
            return;
        }

        $testName = ltrim($methodName, '_');

        if (Common::isCamelCaps($testName, false, true, false) === false)
        {
            $className = $phpcsFile->getDeclarationName($currScope);
            if ($this->isUnitTest($phpcsFile, $stackPointer) === false)
            {
                $error     = 'Method name "%s" is not in camel caps format';
                $errorData = [$className . '::' . $methodName];
                $phpcsFile->addError($error, $stackPointer, 'Production.CamelCapsMethodName.NotCamelCaps', $errorData);
                $phpcsFile->recordMetric($stackPointer, 'CamelCase method name', 'no');
            }
        }
        else
        {
            $phpcsFile->recordMetric($stackPointer, 'CamelCase method name', 'yes');
        }
    }
603642
def handle_endtag(self, tagName):
        '''
            
        '''
        inTag = self._inTag
        try:
            # Handle closing tags which should have been closed but weren't
            foundIt = False
            for i in range(len(inTag)):
                if inTag[i].tagName == tagName:
                    foundIt = True
                    break

            if not foundIt:
                sys.stderr.write('WARNING: found close tag with no matching start.\n')
                return

            while inTag[-1].tagName != tagName:
                oldTag = inTag.pop()
                if oldTag.tagName in PREFORMATTED_TAGS:
                    self.inPreformatted -= 1

                self.currentIndentLevel -= 1

            inTag.pop()
            if tagName != INVISIBLE_ROOT_TAG:
                self.currentIndentLevel -= 1
            if tagName in PREFORMATTED_TAGS:
                self.inPreformatted -= 1
        except:
            pass
381258
function endTagInText(p, token) {
    if (!p.fragmentContext && p.scriptHandler && token.tagName === $.SCRIPT)
        p.scriptHandler(p.document, p.openElements.current);

    p.openElements.pop();
    p.insertionMode = p.originalInsertionMode;
}
1303244
public static synchronized void disableTextDestination() {
		if (textHandler != null) {
			Logger.getLogger("").removeHandler(textHandler);
			// ManagerAdmin.getWsHandlerManager().removeWsHandler(textHandler);
			//735356 Before deleting textHandler, we should close the file. Otherwise file remains open and causes hang during log rotation.
			textHandler.stop();			
			textHandler = null;
		}
	}
1061999
private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
    {
        foreach ($importedParent->childNodes as $childNode) {
            $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
        }
    }
300822
@Override
  protected void visitSoyFileNode(SoyFileNode node) {
    templatesInFile = new LinkedHashSet<>();
    for (TemplateNode template : node.getChildren()) {
      templatesInFile.add(template.getTemplateName());
    }

    calleesNotInFile = new LinkedHashSet<>();
    visitChildren(node);
  }
1072619
protected function _blockEnd($runAfterAll = true)
    {
        if ($runAfterAll) {
            if (Suite::$PHP >= 7 && !defined('HHVM_VERSION')) {
                try {
                    $this->runCallbacks('afterAll', false);
                } catch (Throwable $exception) {
                    $this->_exception($exception);
                }
            } else {
                try {
                    $this->runCallbacks('afterAll', false);
                } catch (Exception $exception) {
                    $this->_exception($exception);
                }
            }
        }

        $this->suite()->autoclear();

        $type = $this->log()->type();
        if ($type === 'failed' || $type === 'errored') {
            $this->_passed = false;
            $this->suite()->failure();
            $this->summary()->log($this->log());
        }

        $this->report('suiteEnd', $this);
    }
807903
public function close()
    {
        if ($this->_fileHandle !== null ) {
            @fclose($this->_fileHandle);
            $this->_fileHandle = null;
        }
    }
36775
protected function checkLastAnnotationTag(File $phpCsFile, int $docBlockStartIndex, int $docBlockEndIndex): void
    {
        $tokens = $phpCsFile->getTokens();

        $prevIndex = $phpCsFile->findPrevious([T_DOC_COMMENT_TAG, T_DOC_COMMENT_STRING], $docBlockEndIndex - 1, $docBlockStartIndex);
        if (!$prevIndex) {
            return;
        }

        $diff = $tokens[$docBlockEndIndex]['line'] - $tokens[$prevIndex]['line'];
        if ($diff < 2) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Expected no extra blank line after tags, got ' . ($diff - 1), $prevIndex, 'NoExtraNewlineAfterTags');
        if (!$fix) {
            return;
        }

        $phpCsFile->fixer->beginChangeset();

        for ($i = $prevIndex; $i < $docBlockEndIndex; $i++) {
            if ($tokens[$i]['line'] <= $tokens[$prevIndex]['line'] || $tokens[$i]['line'] >= $tokens[$docBlockEndIndex]['line']) {
                continue;
            }
            $phpCsFile->fixer->replaceToken($i, '');
        }

        $phpCsFile->fixer->endChangeset();
    }
969092
public function insertWatermarkText($fileName, $text, $rotationAngle)
    {
        //check whether files are set or not
        if ($fileName == '')
            throw new Exception('File not specified');

        //Build JSON to post
        $fieldsArray = array('Text' => $text, 'RotationAngle' => $rotationAngle);
        $json = json_encode($fieldsArray);

        //build URI to insert watermark text
        $strURI = Product::$baseProductUri . '/words/' . $fileName . '/watermark/insertText';

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);

        $v_output = Utils::validateOutput($responseStream);

        if ($v_output === '') {
            //Save docs on server
            $folder = new Folder();
            $outputStream = $folder->GetFile($fileName);
            $outputPath = AsposeApp::$outPutLocation . $fileName;
            Utils::saveFile($outputStream, $outputPath);
            return $outputPath;
        } else
            return $v_output;
    }