@param Operation $operation
@param int       $pos
@param string    $placeholder
@param bool      $stripWrappingTags

@return string
10465
protected function diffIsolatedPlaceholder($operation, $pos, $placeholder, $stripWrappingTags = true)
    {
        $oldText = implode('', $this->findIsolatedDiffTagsInOld($operation, $pos));
        $newText = implode('', $this->newIsolatedDiffTags[$pos]);

        if ($this->isListPlaceholder($placeholder)) {
            return $this->diffList($oldText, $newText);
        } elseif ($this->config->isUseTableDiffing() && $this->isTablePlaceholder($placeholder)) {
            return $this->diffTables($oldText, $newText);
        } elseif ($this->isLinkPlaceholder($placeholder)) {
            return $this->diffElementsByAttribute($oldText, $newText, 'href', 'a');
        } elseif ($this->isImagePlaceholder($placeholder)) {
            return $this->diffElementsByAttribute($oldText, $newText, 'src', 'img');
        }

        return $this->diffElements($oldText, $newText, $stripWrappingTags);
    }
261623
private function extractOperator($expr, $origPos, $tpl)
    {
        $op = $expr[0];
        $validOp = $this->isValidOperator($op);
        if ($validOp) {
            return $op;
        }

        $validVarChr = $this->isValidVarChr($op);
        if (false === $validVarChr) {
            return false;
        } else if (null === $validVarChr) {
            $pctEnc = substr($expr, 1, 2);
            if (!ctype_xdigit($pctEnc) || strlen($pctEnc) !== 2) {
                return false;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
910230
static SpatialOperation parseSpatialOperation(String operation) {
        if (operation == null) {
            throw new IndexException("Operation is required");
        } else if (operation.equalsIgnoreCase("is_within")) {
            return SpatialOperation.IsWithin;
        } else if (operation.equalsIgnoreCase("contains")) {
            return SpatialOperation.Contains;
        } else if (operation.equalsIgnoreCase("intersects")) {
            return SpatialOperation.Intersects;
        } else {
            throw new IndexException("Operation is invalid: {}", operation);
        }
    }
67949
public function mapPos($pos){
       
        foreach ($this->snippets as $k => $v){
            $pos += $k;
            if($pos < $k + strlen($v)){
                break;
            }
            $pos -= ($k + strlen($v));
            
        }
        return $pos;
    }
885545
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getSourceId();
                break;
            case 2:
                return $this->getPageid();
                break;
            case 3:
                return $this->getTitle();
                break;
            case 4:
                return $this->getDisplaytitle();
                break;
            case 5:
                return $this->getPageImageFree();
                break;
            case 6:
                return $this->getWikibaseItem();
                break;
            case 7:
                return $this->getDisambiguation();
                break;
            case 8:
                return $this->getDefaultsort();
                break;
            case 9:
                return $this->getCreatedAt();
                break;
            case 10:
                return $this->getUpdatedAt();
                break;
            default:
                return null;
                break;
        } // switch()
    }
363786
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getSportId();
                break;
            case 2:
                return $this->getName();
                break;
            case 3:
                return $this->getAlternativeName();
                break;
            case 4:
                return $this->getSlug();
                break;
            case 5:
                return $this->getDescription();
                break;
            case 6:
                return $this->getHistory();
                break;
            case 7:
                return $this->getIsTranslation();
                break;
            case 8:
                return $this->getIsRotation();
                break;
            case 9:
                return $this->getIsAcyclic();
                break;
            case 10:
                return $this->getIsCyclic();
                break;
            case 11:
                return $this->getLongitudinalFlags();
                break;
            case 12:
                return $this->getLatitudinalFlags();
                break;
            case 13:
                return $this->getTransversalFlags();
                break;
            case 14:
                return $this->getMovementDescription();
                break;
            case 15:
                return $this->getSequencePictureUrl();
                break;
            case 16:
                return $this->getVariationOfId();
                break;
            case 17:
                return $this->getStartPositionId();
                break;
            case 18:
                return $this->getEndPositionId();
                break;
            case 19:
                return $this->getIsComposite();
                break;
            case 20:
                return $this->getIsMultiple();
                break;
            case 21:
                return $this->getMultipleOfId();
                break;
            case 22:
                return $this->getMultiplier();
                break;
            case 23:
                return $this->getGeneration();
                break;
            case 24:
                return $this->getImportance();
                break;
            case 25:
                return $this->getPictureId();
                break;
            case 26:
                return $this->getVideoId();
                break;
            case 27:
                return $this->getTutorialId();
                break;
            case 28:
                return $this->getKstrukturId();
                break;
            case 29:
                return $this->getFunctionPhaseId();
                break;
            case 30:
                return $this->getObjectId();
                break;
            case 31:
                return $this->getVersion();
                break;
            case 32:
                return $this->getVersionCreatedAt();
                break;
            case 33:
                return $this->getVersionComment();
                break;
            case 34:
                return $this->getVariationOfIdVersion();
                break;
            case 35:
                return $this->getMultipleOfIdVersion();
                break;
            case 36:
                return $this->getKkTrixionarySkillIds();
                break;
            case 37:
                return $this->getKkTrixionarySkillVersions();
                break;
            default:
                return null;
                break;
        } // switch()
    }
569794
public function getHtmlErrorCode($pos, $before=30, $after=40)
    {
        return substr($this->_html, $pos-$before, $before+$after);
    }
1139357
protected function _strip(array $nodes, array $wrapper = array()) {
        $parsed = '';

        if (!$nodes) {
            return $parsed;
        }

        foreach ($nodes as $node) {
            if (is_string($node)) {
                if (!$wrapper) {
                    $parsed .= $this->convertLineBreaks($node);
                } else {
                    $parsed .= $node;
                }
            } else {
                $parsed .= $this->getFilterByTag($node['tag'])->strip($node, $this->_strip($node['children'], $node));
            }
        }

        return $parsed;
    }
163496
protected function __linkLast($arguments,$operation)
	{
		if (isset($arguments[0]))
		{
			$field = $arguments[0];
		}
		else
		{
			$field = '*';
		}
		$this->operationOption['field'] = array($operation . '(' . $field . ')');
		return $this->getScalar();
	}
399324
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getCode();
                break;
            case 1:
                return $this->getAtosCode();
                break;
            case 2:
                return $this->getDecimals();
                break;
            default:
                return null;
                break;
        } // switch()
    }
10110
protected function buildOperation($operation)
    {
        $body      = $this->document->getElementsByTagNameNS(self::SOAP_ENVELOPE, 'Body')->item(0);
        $operation = $this->document->createElementNS(self::ETP_NAME_SPACE, 'etp:' . $operation);

        return $body->appendChild($operation);
    }
1102458
public function parseLinkDestination($str, $pos, $max)
    {
        $lines = 0;
        $start = $pos;
        $result = new \stdClass();
        $result->ok = false;
        $result->pos = 0;
        $result->lines = 0;
        $result->str = '';

        if( $pos === $max ) return $result;

        if ($str[$pos] === '<') {
            $pos++;
            while ($pos < $max) {
                $ch= $str[$pos];
                if ($str[$pos] == "\n" || $this->utils->isSpace($ch)) { return $result; }
                if ($ch === '>') {
                    $result->pos = $pos + 1;
                    $result->str = $this->utils->unescapeAll(substr($str, $start + 1, $pos-($start+1)));
                    $result->ok = true;
                    return $result;
                }
                if ($ch === '\\' && $pos + 1 < $max) {
                    $pos += 2;
                    continue;
                }

                $pos++;
            }

            // no closing '>'
            return $result;
        }

        // this should be ... } else { ... branch

        $level = 0;
        while ($pos < $max) {
            $ch = $str[$pos];

            if ($ch === ' ') { break; }

            // ascii control characters
            $code = ord($ch);
            if ($code < 0x20 || $code === 0x7F) { break; }

            if ($ch === '\\' && $pos + 1 < $max) {
                $pos += 2;
                continue;
            }

            if ($ch === '(' ) {
                $level++;
            }

            if ($ch === ')' ) {
                if ($level === 0) { break; }
                $level--;
            }

            $pos++;
        }

        if ($start === $pos) { return $result; }
        if ($level !== 0) { return $result; }

        $result->str = $this->utils->unescapeAll(substr($str, $start, $pos-$start));
        $result->lines = $lines;
        $result->pos = $pos;
        $result->ok = true;
        return $result;
    }
231141
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getType();
                break;
            case 2:
                return $this->getName();
                break;
            case 3:
                return $this->getDomain();
                break;
            case 4:
                return $this->getApiUrl();
                break;
            case 5:
                return $this->getApiAuthHttpUser();
                break;
            case 6:
                return $this->getApiAuthHttpPassword();
                break;
            case 7:
                return $this->getApiAuthType();
                break;
            case 8:
                return $this->getApiAuthUser();
                break;
            case 9:
                return $this->getApiAuthPassword();
                break;
            case 10:
                return $this->getApiAuthToken();
                break;
            case 11:
                return $this->getApiAuthUrlUserKey();
                break;
            case 12:
                return $this->getApiAuthUrlPwKey();
                break;
            case 13:
                return $this->getCron();
                break;
            case 14:
                return $this->getCustomerId();
                break;
            case 15:
                return $this->getActivated();
                break;
            case 16:
                return $this->getNotes();
                break;
            case 17:
                return $this->getLastRun();
                break;
            case 18:
                return $this->getIncludelog();
                break;
            case 19:
                return $this->getPublicKey();
                break;
            case 20:
                return $this->getWebsiteHash();
                break;
            case 21:
                return $this->getNotificationRecipient();
                break;
            case 22:
                return $this->getNotificationSender();
                break;
            case 23:
                return $this->getNotificationChange();
                break;
            case 24:
                return $this->getNotificationError();
                break;
            default:
                return null;
                break;
        } // switch()
    }
740562
public static function toXmlCompliant($str, $striptags = true)
    {
        if (true === $striptags) {
            $str = strip_tags($str);
        }
        $str = html_entity_decode($str, ENT_COMPAT, 'UTF-8');
        $str = str_replace(array('<', '>', '&'), array('&lt;', '&gt;', '&amp;'), $str);

        return $str;
    }
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;
    }
593059
public function generateImpliedEndTagsThoroughly( $pos ) {
		$stack = $this->stack;
		$current = $stack->current;
		while ( $current && isset( self::$thoroughlyImpliedEndTags[$current->htmlName] ) ) {
			$popped = $stack->pop();
			$this->handler->endTag( $popped, $pos, 0 );
			$current = $stack->current;
		}
	}
474623
public static function parseArguments($source = null, $fpos = 0)
    {
        $parser = new ArgumentLexer($source, $fpos);
        $result = array();
        $current_buffer = &$result;
        $filter_buffer = array();
        $tokens = $parser->parse();
        foreach ($tokens as $token) {
            list($token, $data) = $token;
            if ($token == 'filter_start') {
                $filter_buffer = array();
                $current_buffer = &$filter_buffer;
            } elseif ($token == 'filter_end') {
                if (count($filter_buffer)) {
                    $i = count($result) - 1;
                    if (is_array($result[$i])) {
                        $result[$i]['filters'][] = $filter_buffer;
                    } else {
                        $result[$i] = array(0 => $result[$i], 'filters' => array($filter_buffer));
                    }
                }
                $current_buffer = &$result;
            } elseif ($token == 'boolean') {
                $current_buffer[] = ($data === 'true' ? true : false);
            } elseif ($token == 'name') {
                $current_buffer[] = symbol($data);
            } elseif ($token == 'number' || $token == 'string') {
                $current_buffer[] = $data;
            } elseif ($token == 'named_argument') {
                $last = $current_buffer[count($current_buffer) - 1];
                if (!is_array($last)) {
                    $current_buffer[] = array();
                }

                $namedArgs = &$current_buffer[count($current_buffer) - 1];
                list($name, $value) = array_map('trim', explode(':', $data, 2));

                # if argument value is variable mark it
                $value = self::parseArguments($value);
                $namedArgs[$name] = $value[0];
            } elseif ($token == 'operator') {
                $current_buffer[] = array('operator' => $data);
            }
        }

        return $result;
    }