Add an end tag

@param  string  $name Name of the tag
@param  integer $pos  Position of the tag in the text
@param  integer $len  Length of text consumed by the tag
@param  integer $prio Tag's priority
@return Tag
971302
public function addEndTag($name, $pos, $len, $prio = 0)
	{
		return $this->addTag(Tag::END_TAG, $name, $pos, $len, $prio);
	}
536157
public function end_element($parser, $name)
    {
        // unset schema status
        if (/*preg_match('/types$/', $name) ||*/
        preg_match('/schema$/', $name)
        ) {
            $this->status = "";
            $this->appendDebug($this->currentSchema->getDebug());
            $this->currentSchema->clearDebug();
            $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
            $this->debug('Parsing WSDL schema done');
        }
        if ($this->status == 'schema') {
            $this->currentSchema->schemaEndElement($parser, $name);
        } else {
            // bring depth down a notch
            $this->depth--;
        }
        // end documentation
        if ($this->documentation) {
            //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
            //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
            $this->documentation = false;
        }
    }
138497
protected function makeDefinition($type, $len = 0, $name = null)
    {
        $lpad     = str_repeat($this->indentWith, $this->depth);
        $namePart = '';

        if (!is_null($name) && $name !== '') {
            $namePart = "[<span style='color:#090;'>$name</span>] ";
        }

        return "{$lpad}{$namePart}<span style='color:#00a;'>{$type}</span> ({$len})";
    }
999982
protected function endElement($parser, string $name): void
    {
        $method = $name . 'EndHandler';

        if (method_exists($this, $method)) {
            $this->$method();
        }
    }
953934
protected function isInvalidTextSpan($pos, $len)
	{
		return ($len < 0 || $pos < 0 || $pos + $len > $this->textLen || preg_match('([\\x80-\\xBF])', substr($this->text, $pos, 1) . substr($this->text, $pos + $len, 1)));
	}
120568
public function addLink(string $name, string $link = null, array $arguments = [], int $position = null): Link
	{
		/* @var $item Link */
		$item = $this->addItem(new Link($name, $link, $arguments), $position);
		return $this->getMenu()->attachLink($item);
	}
43176
private function __createAnnotation($name, $string)
    {
        switch ($name) {
            case 'link':
                $annotation = new Annotation\Link($name, $string);
                $annotation->getLinkText();
                break;

            case 'return':
                $annotation = new Annotation\ReturnAnnotation($name, $string);
                $annotation->getReturnType();
                break;

            case 'see':
                $annotation = new Annotation\See($name, $string);
                $annotation->getResource();
                break;

            default:
                $annotation = new Annotation($name, $string);
                break;
        }

        return $annotation;
    }
1009184
public function addInternal($script, $pos = 100, array $attr = array())
    {
        $attr = $this->attr(null, $attr);
        $tag = "<script $attr>$script</script>";
        $this->addElement($pos, $tag);
        return $this;
    }
1048468
public function provideCompletion(
        PhpDocument $doc,
        Position $pos,
        CompletionContext $context = null
    ): CompletionList {
        // This can be made much more performant if the tree follows specific invariants.
        $node = $doc->getNodeAtPosition($pos);

        // Get the node at the position under the cursor
        $offset = $node === null ? -1 : $pos->toOffset($node->getFileContents());
        if (
            $node !== null
            && $offset > $node->getEndPosition()
            && $node->parent !== null
            && $node->parent->getLastChild() instanceof PhpParser\MissingToken
        ) {
            $node = $node->parent;
        }

        $list = new CompletionList;
        $list->isIncomplete = true;

        if ($node instanceof Node\Expression\Variable &&
            $node->parent instanceof Node\Expression\ObjectCreationExpression &&
            $node->name instanceof PhpParser\MissingToken
        ) {
            $node = $node->parent;
        }

        // Inspect the type of expression under the cursor

        $content = $doc->getContent();
        $offset = $pos->toOffset($content);
        if (
            $node === null
            || (
                $node instanceof Node\Statement\InlineHtml
                && (
                    $context !== null
                    // Make sure to not suggest on the > trigger character in HTML
                    && (
                        $context->triggerKind === CompletionTriggerKind::INVOKED
                        || $context->triggerCharacter === '<'
                    )
                )
            )
            || $pos == new Position(0, 0)
        ) {
            // HTML, beginning of file

            // Inside HTML and at the beginning of the file, propose <?php
            $item = new CompletionItem('<?php', CompletionItemKind::KEYWORD);
            $item->textEdit = new TextEdit(
                new Range($pos, $pos),
                stripStringOverlap($doc->getRange(new Range(new Position(0, 0), $pos)), '<?php')
            );
            $list->items[] = $item;

        } elseif (
            $node instanceof Node\Expression\Variable
            && !(
                $node->parent instanceof Node\Expression\ScopedPropertyAccessExpression
                && $node->parent->memberName === $node
            )
        ) {
            // Variables
            //
            //    $|
            //    $a|

            // Find variables, parameters and use statements in the scope
            $namePrefix = $node->getName() ?? '';
            foreach ($this->suggestVariablesAtNode($node, $namePrefix) as $var) {
                $item = new CompletionItem;
                $item->kind = CompletionItemKind::VARIABLE;
                $item->label = '$' . $var->getName();
                $item->documentation = $this->definitionResolver->getDocumentationFromNode($var);
                $item->detail = (string)$this->definitionResolver->getTypeFromNode($var);
                $item->textEdit = new TextEdit(
                    new Range($pos, $pos),
                    stripStringOverlap($doc->getRange(new Range(new Position(0, 0), $pos)), $item->label)
                );
                $list->items[] = $item;
            }

        } elseif ($node instanceof Node\Expression\MemberAccessExpression) {
            // Member access expressions
            //
            //    $a->c|
            //    $a->|

            // Multiple prefixes for all possible types
            $fqns = FqnUtilities\getFqnsFromType(
                $this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
            );

            // The FQNs of the symbol and its parents (eg the implemented interfaces)
            foreach ($this->expandParentFqns($fqns) as $parentFqn) {
                // Add the object access operator to only get members of all parents
                $prefix = $parentFqn . '->';
                $prefixLen = strlen($prefix);
                // Collect fqn definitions
                foreach ($this->index->getChildDefinitionsForFqn($parentFqn) as $fqn => $def) {
                    if (substr($fqn, 0, $prefixLen) === $prefix && $def->isMember) {
                        $list->items[] = CompletionItemFactory::fromDefinition($def);
                    }
                }
            }

        } elseif (
            ($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression ||
            ($scoped = $node) instanceof Node\Expression\ScopedPropertyAccessExpression
        ) {
            // Static class members and constants
            //
            //     A\B\C::$a|
            //     A\B\C::|
            //     A\B\C::$|
            //     A\B\C::foo|
            //
            //     TODO: $a::|

            // Resolve all possible types to FQNs
            $fqns = FqnUtilities\getFqnsFromType(
                $classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier)
            );

            // The FQNs of the symbol and its parents (eg the implemented interfaces)
            foreach ($this->expandParentFqns($fqns) as $parentFqn) {
                // Append :: operator to only get static members of all parents
                $prefix = strtolower($parentFqn . '::');
                $prefixLen = strlen($prefix);
                // Collect fqn definitions
                foreach ($this->index->getChildDefinitionsForFqn($parentFqn) as $fqn => $def) {
                    if (substr(strtolower($fqn), 0, $prefixLen) === $prefix && $def->isMember) {
                        $list->items[] = CompletionItemFactory::fromDefinition($def);
                    }
                }
            }

        } elseif (
            ParserHelpers\isConstantFetch($node)
            // Creation gets set in case of an instantiation (`new` expression)
            || ($creation = $node->parent) instanceof Node\Expression\ObjectCreationExpression
            || (($creation = $node) instanceof Node\Expression\ObjectCreationExpression)
        ) {
            // Class instantiations, function calls, constant fetches, class names
            //
            //    new MyCl|
            //    my_func|
            //    MY_CONS|
            //    MyCla|
            //    \MyCla|

            // The name Node under the cursor
            $nameNode = isset($creation) ? $creation->classTypeDesignator : $node;

            if ($nameNode instanceof Node\QualifiedName) {
                /** @var string The typed name. */
                $prefix = (string)PhpParser\ResolvedName::buildName($nameNode->nameParts, $nameNode->getFileContents());
            } else {
                $prefix = $nameNode->getText($node->getFileContents());
            }

            $namespaceNode = $node->getNamespaceDefinition();
            /** @var string The current namespace without a leading backslash. */
            $currentNamespace = $namespaceNode === null ? '' : $namespaceNode->name->getText();

            /** @var bool Whether the prefix is qualified (contains at least one backslash) */
            $isFullyQualified = false;

            /** @var bool Whether the prefix is qualified (contains at least one backslash) */
            $isQualified = false;

            if ($nameNode instanceof Node\QualifiedName) {
                $isFullyQualified = $nameNode->isFullyQualifiedName();
                $isQualified = $nameNode->isQualifiedName();
            }

            /** @var bool Whether we are in a new expression */
            $isCreation = isset($creation);

            /** @var array Import (use) tables */
            $importTables = $node->getImportTablesForCurrentScope();

            if ($isFullyQualified) {
                // \Prefix\Goes\Here| - Only return completions from the root namespace.
                /** @var $items \Generator|CompletionItem[] Generator yielding CompletionItems indexed by their FQN */
                $items = $this->getCompletionsForFqnPrefix($prefix, $isCreation, false);
            } else if ($isQualified) {
                // Prefix\Goes\Here|
                $items = $this->getPartiallyQualifiedCompletions(
                    $prefix,
                    $currentNamespace,
                    $importTables,
                    $isCreation
                );
            } else {
                // PrefixGoesHere|
                $items = $this->getUnqualifiedCompletions($prefix, $currentNamespace, $importTables, $isCreation);
            }

            $list->items = array_values(iterator_to_array($items));
            foreach ($list->items as $item) {
                // Remove ()
                if (is_string($item->insertText) && substr($item->insertText, strlen($item->insertText) - 2) === '()') {
                    $item->insertText = substr($item->insertText, 0, -2);
                }
            }

        }
        return $list;
    }
1142313
public function endObjectElement($name)
    {
        $this->checkEndObjectElement($name);

        $this->json = $this->json->getParent();
    }
719099
public static function createByName(string $name, string $locale = null, string $group = null): Tag
    {
        $locale = $locale ?? app()->getLocale();

        return static::create([
            'name' => [$locale => $name],
            'group' => $group,
        ]);
    }
371969
function whitespaceEndPos( $tpl, &$text, $currentPosition, $textLength )
    {
        if ( $currentPosition >= $textLength )
            return $currentPosition;
        while( $currentPosition < $textLength and
               ( $text[$currentPosition] === ' '
                 or $text[$currentPosition] === "\n"
                 or $text[$currentPosition] === "\t"
                 or $text[$currentPosition] === "\r" ) )
        {
            ++$currentPosition;
        }
        return $currentPosition;
    }
89548
public static function pos(string $list, string $item, string $separator, string $tag = ''): int
    {
        $items = self::explode($separator, $list);
        $pos = array_search($tag . $item . $tag, $items);
        if ($pos === false) {
            $pos = -1;
        }
        return $pos;
    }
53730
function endElement($parser, $name) {
    if (substr($this->elementValue, 0, 1) == "\n") $this->elementValue = substr($this->elementValue, 1);
    $this->deserializedResponse[$this->elementName]= $this->elementValue;
    $this->elementName = "";
    $this->elementValue = "";
  }
1174354
public function tag(string $name, string $repo, string $tag = 'latest')
    {
        $data = [
            'repo' => $repo,
            'tag' => $tag,
        ];

        $url = self::$base_url.'/'.$name.'/tag?'.http_build_query($data);

        return self::$curl->post($url);
    }
875222
function end_element($parser, $name)
    {
        // position of current element is equal to the last value left in depth_array for my depth
        $pos = $this->depth_array[$this->depth--];

        // get element prefix
        if (strpos($name, ':')) {
            // get ns prefix
            $prefix = substr($name, 0, strpos($name, ':'));
            // get unqualified name
            $name = substr(strstr($name, ':'), 1);
        }

        // build to native type
        if (isset($this->body_position) && $pos > $this->body_position) {
            // deal w/ multirefs
            if (isset($this->message[$pos]['attrs']['href'])) {
                // get id
                $id = substr($this->message[$pos]['attrs']['href'], 1);
                // add placeholder to href array
                $this->multirefs[$id][$pos] = 'placeholder';
                // add set a reference to it as the result value
                $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
                // build complexType values
            } elseif ($this->message[$pos]['children'] != '') {
                // if result has already been generated (struct/array)
                if (!isset($this->message[$pos]['result'])) {
                    $this->message[$pos]['result'] = $this->buildVal($pos);
                }
                // build complexType values of attributes and possibly simpleContent
            } elseif (isset($this->message[$pos]['xattrs'])) {
                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
                    $this->message[$pos]['xattrs']['!'] = NULL;
                } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
                    if (isset($this->message[$pos]['type'])) {
                        $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
                    } else {
                        $parent = $this->message[$pos]['parent'];
                        if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
                            $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
                        } else {
                            $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
                        }
                    }
                }
                $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
                // set value of simpleType (or nil complexType)
            } else {
                //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
                    $this->message[$pos]['xattrs']['!'] = NULL;
                } elseif (isset($this->message[$pos]['type'])) {
                    $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
                } else {
                    $parent = $this->message[$pos]['parent'];
                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
                        $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
                    } else {
                        $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
                    }
                }

                /* add value to parent's result, if parent is struct/array
				$parent = $this->message[$pos]['parent'];
				if($this->message[$parent]['type'] != 'map'){
					if(strtolower($this->message[$parent]['type']) == 'array'){
						$this->message[$parent]['result'][] = $this->message[$pos]['result'];
					} else {
						$this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
					}
				}
				*/
            }
        }

        // for doclit
        if ($this->status == 'header') {
            if ($this->root_header != $pos) {
                $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
            }
        } elseif ($pos >= $this->root_struct) {
            $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
        }
        // switch status
        if ($pos == $this->root_struct) {
            $this->status                = 'body';
            $this->root_struct_namespace = $this->message[$pos]['namespace'];
        } elseif ($pos == $this->root_header) {
            $this->status = 'envelope';
        } elseif ($name == 'Body' && $this->status == 'body') {
            $this->status = 'envelope';
        } elseif ($name == 'Header' && $this->status == 'header') { // will never happen
            $this->status = 'envelope';
        } elseif ($name == 'Envelope' && $this->status == 'envelope') {
            $this->status = '';
        }
        // set parent back to my parent
        $this->parent = $this->message[$pos]['parent'];
    }
632638
public function addVerbatim($pos, $len, $prio = 0)
	{
		return $this->addTag(Tag::SELF_CLOSING_TAG, 'v', $pos, $len, $prio);
	}