@param AbstractLineString[] $rings

@return array
186395
protected function validatePolygonValue(array $rings)
    {
        foreach ($rings as &$ring) {
            $ring = $this->validateRingValue($ring);
        }

        return $rings;
    }
577001
public static function getBreadcrumbs(AbstractNavigationNode $node) {

        $breadcrumbs = [];

        if (true === ($node instanceof NavigationNode || $node instanceof BreadcrumbNode) && true === $node->getActive()) {
            $breadcrumbs[] = $node;
        }

        foreach ($node->getNodes() as $current) {
            if (false === ($current instanceof AbstractNavigationNode)) {
                continue;
            }
            $breadcrumbs = array_merge($breadcrumbs, self::getBreadcrumbs($current));
        }

        return $breadcrumbs;
    }
256982
protected function findLineages($data) {
		if (preg_match_all("/".$this->lineageMatch."/",$data,$matches)) {
			return array_unique($matches[$this->lineageMatchKey]);
		}
		return array();
	}
375101
private function getAbstracts()
    {
        $r = '';

        // Inside abstracts
        foreach ($this->modules as $module) {
            $abstracts = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/abstract');

            foreach ($abstracts as $abstract) {
                $abstractAttributes = (array)$abstract;
                $abstractAttributes = $abstractAttributes['@attributes'];

                $this->checkMandatoryAttributes('Abstract in module ' . $module, $abstractAttributes, ['name']);

                $abstractName = $abstractAttributes['name'];

                $this->insideAbstracts[$module][] = $abstractName;

                $this->checkMandatoryAttributes(
                    'Abstract ' . $abstractName . ' in module ' . $module,
                    $abstractAttributes,
                    ['left', 'top']
                );

                $r .= 'var s = new Abstract(\'' . $abstractName . '\',\'' . str_replace(
                    '\\',
                    '\\\\',
                    $module
                ) . '\');' . PHP_EOL;
                $r .= 's.moveTo(\'' . ( $abstractAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $abstractAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL;

                $r .= $this->getClassLikeProperties($abstractAttributes, 's');

                $r .= 's.setModule(Container.prototype.getContainerByName(\'' . str_replace(
                    '\\',
                    '\\\\',
                    $module
                ) . '\').getId());' . PHP_EOL;
            }
        }

        // Outside abstracts
        $abstracts = (array)$this->xml->xpath('/draggy/loose/abstract');

        foreach ($abstracts as $abstract) {
            $abstractAttributes = (array)$abstract;
            $abstractAttributes = $abstractAttributes['@attributes'];

            $this->checkMandatoryAttributes('Loose abstract', $abstractAttributes, ['name']);

            $abstractName = $abstractAttributes['name'];

            $this->outsideAbstracts[] = $abstractName;

            $this->checkMandatoryAttributes('Loose abstract ' . $abstractName, $abstractAttributes, ['left', 'top']);

            $r .= 'var s = new Abstract(\'' . $abstractName . '\');' . PHP_EOL;
            $r .= 's.moveTo(\'' . ( $abstractAttributes['left'] ) . 'px\',\'' . ( $abstractAttributes['top'] ) . 'px\');' . PHP_EOL;

            $r .= $this->getClassLikeProperties($abstractAttributes, 's');
        }

        return $r;
    }
1074919
public static function grep(array $arr, string $pattern, int $flags = 0): array
    {
        return Strings::pcre('\preg_grep', [$pattern, $arr, $flags]);
    }
1025
protected function getTokenStrings(int $row, array $tokens): array
    {
        $pieces = [];
        foreach ($tokens as $key => $token) {
            if ($token['line'] > $row) {
                break;
            }
            if ($token['line'] < $row) {
                continue;
            }
            if ($this->verbose) {
                $type = $token['type'];
                $content = $token['content'];
                $content = '`' . str_replace(["\r\n", "\n", "\r", "\t"], ['\r\n', '\n', '\r', '\t'], $content) . '`';

                unset($token['type']);
                unset($token['content']);
                $token['content'] = $content;

                $tokenList = [];
                foreach ($token as $k => $v) {
                    if (is_array($v)) {
                        if (empty($v)) {
                            continue;
                        }
                        $v = json_encode($v);
                    }
                    $tokenList[] = $k . '=' . $v;
                }
                $pieces[] = $type . ' (' . $key . ') ' . implode(', ', $tokenList);
            } else {
                $pieces[] = $token['type'];
            }
        }
        if ($this->verbose) {
            return $pieces;
        }
        return [implode(' ', $pieces)];
    }
32066
private List<Integer[]> getRingSystem(IAtomContainer mol, IRingSet ringSet) {
        List<Integer[]> bondsArray;
        bondsArray = new ArrayList<Integer[]>();
        for (int r = 0; r < ringSet.getAtomContainerCount(); ++r) {
            IRing ring = (IRing) ringSet.getAtomContainer(r);
            Integer[] bondNumbers = new Integer[ring.getBondCount()];
            for (int i = 0; i < ring.getBondCount(); ++i) {
                bondNumbers[i] = mol.indexOf(ring.getBond(i));
            }
            bondsArray.add(bondNumbers);
        }
        return bondsArray;
    }
628912
public static function lines(string $str): array
    {
        $lines = BaseStringy::create($str)->lines();

        foreach ($lines as $i => $line) {
            $lines[$i] = $line;
        }

        /** @var string[] $lines */
        return $lines;
    }
369236
protected function _processMethods($nodes)
    {
        foreach ($nodes as $child) {
            if (!$child->processable) {
                continue;
            }
            if ($child->type !== 'function' || !$child->isMethod || isset($child->visibility['abstract'])) {
                continue;
            }
            $namespace = $child->namespace ? $child->namespace->name . '\\' : '';
            $class = $namespace . $child->parent->name;

            if (!$this->processable($class, $child->name)) {
                continue;
            }
            $params = $child->argsToParams();
            $args = $params ? "[{$params}] + " : '';
            $before = new NodeDef("return \\Lead\Filter\\Filters::run(isset(\$this) ? \$this : get_called_class(), __FUNCTION__, " . $args . "func_get_args(), ", 'code');
            $before->parent = $child;
            $before->processable = false;
            $before->namespace = $child->namespace;

            $comma = count($child->args) ? ', ' : '';

            $closure = new FunctionDef("function (\$next{$comma}" . $params . ") {");
            $closure->parent = $child;
            $closure->namespace = $child->namespace;
            $closure->isClosure = true;
            $closure->tree = $child->tree;
            foreach($closure->tree as $item) {
                $item->parent = $closure;
            }
            $closure->close = '});';

            $child->tree = [];
            $child->tree[] = $before;
            $child->tree[] = $closure;
        }
    }
233224
public function getLatLngs($preferFlat = true)
    {
        if ($preferFlat) {
            $value = [];

            foreach ($this->latLngs as $ring) {
                $value = array_merge($value, $ring);
            }

            return $value;
        }

        return $this->latLngs;
    }
166699
function LinesToArray($text)
    {
        $result = array();
        $lines = Str::SplitLines($text);
        foreach ($lines as $line)
        {
            $line = trim($line);
            if (!$line)
            {
                continue;
            }
            $pos = strpos($line, $this->separator);
            $key = $line;
            $value = '';
            if ($pos !== false)
            {
                $key = substr($line, 0, $pos);
                $value = substr($line, $pos + strlen($this->separator));
            }
            $result[trim($key)] = trim($value);
        }
        return $result;
    }
1163820
public function interiorRingN(int $n) : LineString
    {
        if ($n === 0 || ! isset($this->rings[$n])) {
            throw new NoSuchGeometryException('There is no interior ring in this Polygon at index ' . $n);
        }

        return $this->rings[$n];
    }
646134
public function convertSplittersToRegexPattern( $splitters ) {
	    $regex_parts = array();
	    foreach ( $splitters as $part ) {
		    $part = preg_quote( $part );

		    switch ( $part ) {
			    case "\r\n":
				    $part = '\r\n';
				    break;
			    case "\t":
				    $part = '\t';
				    break;
			    case "\n":
				    $part = '\n';
				    break;
			    case " ":
				    $part = '\s';
				    break;
			    case "/":
				    $part = "\/";
				    break;
			    case "/\*":
				    $part = "\/\*";
				    break;
			    case "\*/":
				    $part = "\*\/";
				    break;
		    }

		    $regex_parts[] = $part;
	    }

	    $pattern = implode( '|', $regex_parts );

	    return '/(' . $pattern . ')/';
    }
947853
protected function recurseArrayForTokens($arr, $tokens)
    {
        $out = [];
        foreach ($arr as $name => $value) {
            if (is_array($value)) {
                $out[$name] = $this->recurseArrayForTokens($value, $tokens);
                continue;
            }
            if (is_string($value)) {
                foreach ($tokens as $token => $tval) {
                    $value = str_replace($token, $tval, $value);
                }
                $out[$name] = $value;
                continue;
            }
            $out[$name] = $value;
        }

        return $out;
    }
1221795
private function extractUseStatements(\ArrayIterator $tokens)
    {
        $extractedUseStatements = [];
        $groupedNs = '';
        $currentNs = '';
        $currentAlias = null;
        $state = 'start';

        $i = 0;
        while ($tokens->valid()) {
            $i += 1;
            $currentToken = $tokens->current();
            $tokenId = is_string($currentToken) ? $currentToken : $currentToken[0];
            $tokenValue = is_string($currentToken) ? null : $currentToken[1];
            switch ($state) {
                case 'start':
                    switch ($tokenId) {
                        case T_STRING:
                        case T_NS_SEPARATOR:
                            $currentNs .= $tokenValue;
                            break;
                        case T_CURLY_OPEN:
                        case '{':
                            $state = 'grouped';
                            $groupedNs = $currentNs;
                            break;
                        case T_AS:
                            $state = 'start-alias';
                            break;
                        case self::T_LITERAL_USE_SEPARATOR:
                        case self::T_LITERAL_END_OF_USE:
                            $state = 'end';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'start-alias':
                    switch ($tokenId) {
                        case T_STRING:
                            $currentAlias .= $tokenValue;
                            break;
                        case self::T_LITERAL_USE_SEPARATOR:
                        case self::T_LITERAL_END_OF_USE:
                            $state = 'end';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'grouped':
                    switch ($tokenId) {
                        case T_STRING:
                        case T_NS_SEPARATOR:
                            $currentNs .= $tokenValue;
                            break;
                        case T_AS:
                            $state = 'grouped-alias';
                            break;
                        case self::T_LITERAL_USE_SEPARATOR:
                            $state = 'grouped';
                            $extractedUseStatements[$currentAlias ?: $currentNs] = $currentNs;
                            $currentNs = $groupedNs;
                            $currentAlias = null;
                            break;
                        case self::T_LITERAL_END_OF_USE:
                            $state = 'end';
                            break;
                        default:
                            break;
                    }
                    break;
                case 'grouped-alias':
                    switch ($tokenId) {
                        case T_STRING:
                            $currentAlias .= $tokenValue;
                            break;
                        case self::T_LITERAL_USE_SEPARATOR:
                            $state = 'grouped';
                            $extractedUseStatements[$currentAlias ?: $currentNs] = $currentNs;
                            $currentNs = $groupedNs;
                            $currentAlias = null;
                            break;
                        case self::T_LITERAL_END_OF_USE:
                            $state = 'end';
                            break;
                        default:
                            break;
                    }
            }

            if ($state === 'end') {
                break;
            }

            $tokens->next();
        }

        if ($groupedNs !== $currentNs) {
            $extractedUseStatements[$currentAlias ?: $currentNs] = $currentNs;
        }

        return $extractedUseStatements;
    }
938676
protected function _parse(array $nodes, array $wrapper = array()) {
        $parsed = '';

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

        foreach ($nodes as $node) {
            if (is_string($node)) {
                $string = $this->_triggerHook('beforeContent', $node);

                if (!$wrapper) {
                    $string = $this->convertLineBreaks($string);
                }

                $string = $this->_triggerHook('afterContent', $string);

            } else {
                $string = $this->getFilterByTag($node['tag'])->parse($node, $this->_parse($node['children'], $node));
            }

            $parsed .= $string;
        }

        return $parsed;
    }
53445
private function getMethods($methods)
    {
        $methods = $methods ?? $this->methods;

        if (is_string($methods))
            $methods = (array) $methods;

        return is_array($methods) ? array_map('strtoupper', $methods) : [];
    }