@param $name
@param $string

@return Zone

@throws ParseException
337598
public function makeZone($name, $string): Zone
    {
        $this->zone = new Zone($name);
        $this->string = Normaliser::normalise($string);

        foreach (explode(Tokens::LINE_FEED, $this->string) as $line) {
            $this->processLine($line);
        }

        return $this->zone;
    }
471564
public function findSectionOrCreate($name, Section $parent = null, $priority = 1)
    {
        if (is_null($parent)) {
            $parent = $this->getRootSection();
        }

        $section = $this->findSection($name, $parent);

        if (is_null($section)) {
            $section = $this->addSection($name, $parent, $priority);
        }

        return $section;
    }
1296913
protected function parseExtend($name)
    {
        $this->setExtendedClass(null);

        $nameParts = explode('@extend', $name);
        $name = trim($nameParts[0]);
        if (count($nameParts) > 1) {
            $this->setExtendedClass($nameParts[1]);
        }

        return $name;
    }
499403
public function parseDate($string)
    {
        try {
            return new \DateTime($string);
        } catch (ParsingException $ex) {
            $exception = new ParsingException('The date is '
                      . 'not parsable', 0, $ex);
            throw $exception;
        }
        
    }
814666
public static function parseString($string)
    {
        $groups = [];

        $index = 0;

        $matchSection = false;

        foreach (explode(PHP_EOL, $string) as $line) {
            $line = trim($line);

            if ('' == $line || starts_with($line, '#')) {
                continue;
            }

            // Keys and values may get separated via an equals, so we'll parse them both
            // out here and hang onto their values. We will also lower case this keys
            // and unquotes the values so they are properly formatted for next use.
            if (preg_match('/^\s*(\S+)\s*=(.*)$/', $line, $match)) {
                $key = strtolower($match[1]);

                $value = self::unquote($match[2]);
            }

            // Keys and values may also get separated via a space, so we will parse them
            // out here and hang onto their values. We will also lower case this keys
            // and unquotes the values so they are properly formatted for next use.
            else {
                $segments = preg_split('/\s+/', $line, 2);

                $key = strtolower($segments[0]);

                $value = self::unquote($segments[1]);
            }

            // The configuration file contains sections separated by Host and / or Match
            // specifications. Therefore, if we come across a Host keyword we start a
            // new group. If it's a Match we ignore declarations until next 'Host'.
            if ('host' === $key) {
                $index++;

                $matchSection = false;
            } elseif ('match' === $key) {
                $matchSection = true;
            }

            if (! $matchSection) {
                $groups[$index][$key] = $value;
            }
        }

        return new self(array_values($groups));
    }
918698
public static function createFromString($string)
    {
        if (preg_match('/^(?:(.+) )?<(.+)>$/', $string, $vars)) {
            $name  = $vars[1] === '' ? null : $vars[1];
            $email = $vars[2] === '' ? null : $vars[2];
            return new Person($name, $email);
        }

        throw new \InvalidArgumentException(sprintf('Unable to parse Person "%s".', $string));
    }
1258339
public static function parse(string $text) : TimeZone
    {
        $text = (string) $text;

        if ($text === 'Z' || $text === 'z') {
            return TimeZoneOffset::utc();
        }

        if ($text === '') {
            throw new DateTimeParseException('The string is empty.');
        }

        if ($text[0] === '+' || $text[0] === '-') {
            return TimeZoneOffset::parse($text);
        }

        return TimeZoneRegion::parse($text);
    }
34035
public static function fromString($string)
    {
        list($lat, $long) = explode(',', $string);
        return new self($lat, $long);
    }
963900
public function tokenize($string)
    {
        $line     = 1;
        $position = 1;
        $tokens   = array();

        while (strlen($string)) {
            foreach ($this->expressions as $rule) {
                if (!preg_match($rule['match'], $string, $match)) {
                    continue;
                }

                // Remove matched string from input
                $string = substr($string, strlen($match[0]));

                // Update position in file
                $line += substr_count($match[0], "\n");
                if (($pos = strrpos($match[0], "\n")) !== false) {
                    $position  = strrpos($match[0], "\n") + 1;
                } else {
                    $position += strlen($match[0]);
                }

                // Skip irrelevant rules
                if (in_array($rule['type'], $this->ignoreTokens)) {
                    continue 2;
                }

                // Add all other rules including their match to the token array
                $match = $this->removeNumericKeys($match);
                $tokens[] = new Token($rule['type'], $line, $position, $match);
                continue 2;
            }

            throw new \RuntimeException(
                "Could not parse string: '" . substr($string, 0, 20) . "' in line $line at position $position."
            );
        }

        $tokens[] = new Token(self::T_EOF, $line, $position, null);
        return $tokens;
    }
1250381
public function offsetSet($offset, $string)
    {
        $this->string = Mbstring::substrReplace($this->string, $string, $offset, 1, $this->encoding);
    }
955914
public function parse($string)
    {
        global $matchedNotes;

        $keyPrefixLen = $this->keyPrefix ? strlen($this->keyPrefix) : 0;
        
        $data = array();
        $toDelete = [];
        $lines = preg_split('@\n@', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);

        foreach ($lines as list($l, $offset)) {
            $len = strlen($l);
            $l = trim($l);
            $offset += $len - strlen($l);

            if ($l && $l[0] == '@') {
                $curDelete = trim($l);
                $l = substr($l, 1);
                $d = preg_split('/\s+/', $l, 2, PREG_SPLIT_OFFSET_CAPTURE);
                
                $key = $d[0][0];
                if ($this->keyPrefix) {
                    if (strpos($key, $this->keyPrefix)!==0)
                        continue;
                    $key = substr($key, $keyPrefixLen);
                }
                
                $key = preg_split(
                    "/(
                           \]\[
                        |  \[
                        |  \]\.   # when php style abuts dot notation (foo[a].b)
                        |  \]
                        |  \.)
                    /x", 
                    rtrim($key, ']')
                );
                
                if (isset($d[1])) {
                    $value = $d[1][0];
                }
                else {
                    $value = $this->defaultValue;
                }
                
                $current = &$data;
                $found = array();
                foreach ($key as $part) {
                    if ($current && !is_array($current)) {
                        throw new RewriteException("Key at path ".implode('.', $found)." already had non-array value, tried to set key $part");
                    }

                    if (!$found) {
                        if (in_array($part, $matchedNotes)) {
                            $toDelete[] = $curDelete;
                        }
                    }
                    
                    $found[] = $part;
                    
                    // if the last segment is empty, it means "@key[] value" or "@key. value" was used,
                    //  so we should just assign the next key
                    if ($part !== "")
                        $current = &$current[$part];
                    else
                        $current = &$current[];
                }
                
                if ($current === null)
                    $current = $value;
                elseif (!is_array($current))
                    $current = array($current, $value);
                else
                    $current[] = $value;
                
                unset($current);
            }
        }
        return [$data, $toDelete];
    }
287705
public static function fromHeader(string $string): Cookie
    {
        $parts = array_map('trim', explode('=', $string, 2));

        if (2 !== count($parts)) {
            throw new InvalidValueException('Invalid cookie header format.');
        }

        list($name, $value) = $parts;

        return new self($name, $value);
    }
469563
public static function fromXml(string $string) : self
    {
        $xml = new \SimpleXMLElement($string);

        $data = static::xmlToArray($xml);

        return static::decompile($data);
    }
2249
public function parse($string) {
        $output = new \SplQueue();
        $operator = new \SplStack();

        // Convert the string to tokens for the lexer.
        $tokens = $this->lexer->tokenize($string);

        // while there are tokens to be read:
        while (count($tokens)) {
            // read a token.
            $token = array_shift($tokens);

            // if the token is a number, then push it to the output queue.
            if ($token->isValue()) {
                $output->push($token);
                continue;
            }

            // if the token is a function, then push it onto the operator stack.
            if ($token->isFunction()) {
                $operator->push($token);
                continue;
            }

            // if the token is a function argument separator:
            if ($token->getValue() === ',') {
                while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
                    $output->push($operator->pop());
                }

                if ($operator->isEmpty()) {
                    throw new ParserException('Mismatched parentheses or misplaced comma.');
                }

                continue;
            }

            // if the token is an operator, then:
            if ($token->isOperator()) {
                // while (
                //  (there is an operator at the top of the operator stack with greater precedence) or
                //  (the operator at the top of the operator stack has equal precedence and the operator is left associative)) and
                //  (the operator at the top of the stack is not a left bracket):
                //     pop operators from the operator stack, onto the output queue.
                while (($op = $this->getTop($operator)) && $op->isOperator() && $token->hasHigherPriority($op)) {
                    $output->push($operator->pop());
                }

                // push the read operator onto the operator stack.
                $operator->push($token);
                continue;
            }

            // if the token is a left bracket (i.e. "("), then:
            if ($token->getValue() === '(') {
                // push it onto the operator stack.
                $operator->push($token);
                continue;
            }

            // if the token is a right bracket (i.e. ")"), then:
            if ($token->getValue() === ')') {
                // while the operator at the top of the operator stack is not a left bracket:
                while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
                    // pop operators from the operator stack onto the output queue.
                    $output->push($operator->pop());
                }

                // /* if the stack runs out without finding a left bracket, then there are mismatched parentheses. */
                if ($operator->isEmpty()) {
                    throw new ParserException('Mismatched parentheses');
                }

                // pop the left bracket from the stack.
                $operator->pop();

                // If the token at the top of the stack is a function token, pop it onto the output queue.
                if (($op = $this->getTop($operator)) && $op->isFunction()) {
                    $output->push($operator->pop());
                }
            }
        }

        // if there are no more tokens to read:
        // while there are still operator tokens on the stack:
        while (!$operator->isEmpty()) {
            // /* if the operator token on the top of the stack is a bracket, then there are mismatched parentheses. */
            if (is_null($operator->top()->getOperator())) {
                throw new ParserException('Mismatched parentheses or misplaced comma.');
            }

            // pop the operator onto the output queue.
            $output->push($operator->pop());
        }

        // exit.
        return iterator_to_array($output);
    }
867007
public static function sequence(string $name): self
    {
        if (!isset(self::$instances[$name])) {
            self::$instances[$name] = new self();
        }

        return self::$instances[$name];
    }
1035738
protected function formatIndex($name)
    {
        if (\is_string($name)) {
            $exp = explode('.', $name);

            if (0 < \count($exp)) {
                $name = $exp[\count($exp) - 1];
            }
        }

        return $name;
    }
1126215
public static function fromString($string)
	{
		$bits = new BitArray(strlen($string));
		$ord = 0;

		for ($offset = 0; $offset < $bits->size; $offset++)
		{
			if ($string[$offset] !== '0')
			{
				$ord |= 1 << $offset % 8;
			}

			if ($offset % 8 === 7)
			{
				$bits->data[(int) ($offset / 8)] = chr($ord);
				$ord = 0;
			}
		}

		if ($offset % 8 !== 0)
		{
			$bits->data[(int) ($offset / 8)] = chr($ord);
		}

		return $bits;
	}