X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fyaml%2FParser.php;fp=vendor%2Fsymfony%2Fyaml%2FParser.php;h=36c9f1d9137022b48bc101697c17e40004494198;hp=7446ae065cd409a16b1d56a8f712ed61606832ca;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/symfony/yaml/Parser.php b/vendor/symfony/yaml/Parser.php index 7446ae065..36c9f1d91 100644 --- a/vendor/symfony/yaml/Parser.php +++ b/vendor/symfony/yaml/Parser.php @@ -38,14 +38,14 @@ class Parser public function __construct() { - if (func_num_args() > 0) { + if (\func_num_args() > 0) { @trigger_error(sprintf('The constructor arguments $offset, $totalNumberOfLines, $skippedLineNumbers of %s are deprecated and will be removed in 4.0', self::class), E_USER_DEPRECATED); $this->offset = func_get_arg(0); - if (func_num_args() > 1) { + if (\func_num_args() > 1) { $this->totalNumberOfLines = func_get_arg(1); } - if (func_num_args() > 2) { + if (\func_num_args() > 2) { $this->skippedLineNumbers = func_get_arg(2); } } @@ -92,7 +92,7 @@ class Parser */ public function parse($value, $flags = 0) { - if (is_bool($flags)) { + if (\is_bool($flags)) { @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); if ($flags) { @@ -102,7 +102,7 @@ class Parser } } - if (func_num_args() >= 3) { + if (\func_num_args() >= 3) { @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED); if (func_get_arg(2)) { @@ -110,7 +110,7 @@ class Parser } } - if (func_num_args() >= 4) { + if (\func_num_args() >= 4) { @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED); if (func_get_arg(3)) { @@ -169,7 +169,7 @@ class Parser $this->locallySkippedLineNumbers = array(); if (null === $this->totalNumberOfLines) { - $this->totalNumberOfLines = count($this->lines); + $this->totalNumberOfLines = \count($this->lines); } if (!$this->moveToNextLine()) { @@ -234,7 +234,7 @@ class Parser // this is a compact notation element, add to next block and parse $block = $values['value']; if ($this->isNextLineIndented()) { - $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + strlen($values['leadspaces']) + 1); + $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1); } $data[] = $this->parseBlock($this->getRealCurrentLineNb(), $block, $flags); @@ -247,7 +247,7 @@ class Parser } } elseif ( self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P.+))?$#u', rtrim($this->currentLine), $values) - && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'"))) + && (false === strpos($values['key'], ' #') || \in_array($values['key'][0], array('"', "'"))) ) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine, $this->filename); @@ -271,13 +271,13 @@ class Parser throw $e; } - if (!is_string($key) && !is_int($key)) { + if (!\is_string($key) && !\is_int($key)) { $keyType = is_numeric($key) ? 'numeric key' : 'non-string key'; @trigger_error($this->getDeprecationMessage(sprintf('Implicit casting of %s to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.', $keyType)), E_USER_DEPRECATED); } // Convert float keys to strings, to avoid being converted to integers by PHP - if (is_float($key)) { + if (\is_float($key)) { $key = (string) $key; } @@ -296,7 +296,7 @@ class Parser $refValue = (array) $refValue; } - if (!is_array($refValue)) { + if (!\is_array($refValue)) { throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -313,7 +313,7 @@ class Parser $parsed = (array) $parsed; } - if (!is_array($parsed)) { + if (!\is_array($parsed)) { throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -326,7 +326,7 @@ class Parser $parsedItem = (array) $parsedItem; } - if (!is_array($parsedItem)) { + if (!\is_array($parsedItem)) { throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem, $this->filename); } @@ -407,7 +407,7 @@ class Parser } // 1-liner optionally followed by newline(s) - if (is_string($value) && $this->lines[0] === trim($value)) { + if (\is_string($value) && $this->lines[0] === trim($value)) { try { $value = Inline::parse($this->lines[0], $flags, $this->refs); } catch (ParseException $e) { @@ -470,7 +470,7 @@ class Parser $data = new TaggedValue($tag, $data); } - if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !is_object($data) && 'mapping' === $context) { + if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !\is_object($data) && 'mapping' === $context) { $object = new \stdClass(); foreach ($data as $key => $value) { @@ -533,7 +533,7 @@ class Parser */ private function getCurrentLineIndentation() { - return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' ')); + return \strlen($this->currentLine) - \strlen(ltrim($this->currentLine, ' ')); } /** @@ -549,11 +549,6 @@ class Parser private function getNextEmbedBlock($indentation = null, $inSequence = false) { $oldLineIndentation = $this->getCurrentLineIndentation(); - $blockScalarIndentations = array(); - - if ($this->isBlockScalarHeader()) { - $blockScalarIndentations[] = $oldLineIndentation; - } if (!$this->moveToNextLine()) { return; @@ -612,30 +607,9 @@ class Parser $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); - if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) { - $blockScalarIndentations[] = $this->getCurrentLineIndentation(); - } - - $previousLineIndentation = $this->getCurrentLineIndentation(); - while ($this->moveToNextLine()) { $indent = $this->getCurrentLineIndentation(); - // terminate all block scalars that are more indented than the current line - if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && '' !== trim($this->currentLine)) { - foreach ($blockScalarIndentations as $key => $blockScalarIndentation) { - if ($blockScalarIndentation >= $indent) { - unset($blockScalarIndentations[$key]); - } - } - } - - if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) { - $blockScalarIndentations[] = $indent; - } - - $previousLineIndentation = $indent; - if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { $this->moveToPreviousLine(); break; @@ -669,7 +643,7 @@ class Parser */ private function moveToNextLine() { - if ($this->currentLineNb >= count($this->lines) - 1) { + if ($this->currentLineNb >= \count($this->lines) - 1) { return false; } @@ -765,7 +739,7 @@ class Parser } } - for ($i = 0, $linesCount = count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) { + for ($i = 0, $linesCount = \count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) { if ('' === $lines[$i]) { $value .= "\n"; $previousLineBlank = true; @@ -782,7 +756,7 @@ class Parser $parsedValue = Inline::parse($value, $flags, $this->refs); - if ('mapping' === $context && is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) { + if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) { throw new ParseException('A colon cannot be used in an unquoted mapping value.', $this->getRealCurrentLineNb() + 1, $value, $this->filename); } @@ -826,7 +800,7 @@ class Parser // determine indentation if not specified if (0 === $indentation) { if (self::preg_match('/^ +/', $this->currentLine, $matches)) { - $indentation = strlen($matches[0]); + $indentation = \strlen($matches[0]); } } @@ -839,7 +813,7 @@ class Parser self::preg_match($pattern, $this->currentLine, $matches) ) ) { - if ($isCurrentLineBlank && strlen($this->currentLine) > $indentation) { + if ($isCurrentLineBlank && \strlen($this->currentLine) > $indentation) { $blockLines[] = substr($this->currentLine, $indentation); } elseif ($isCurrentLineBlank) { $blockLines[] = ''; @@ -869,7 +843,7 @@ class Parser $previousLineIndented = false; $previousLineBlank = false; - for ($i = 0, $blockLinesCount = count($blockLines); $i < $blockLinesCount; ++$i) { + for ($i = 0, $blockLinesCount = \count($blockLines); $i < $blockLinesCount; ++$i) { if ('' === $blockLines[$i]) { $text .= "\n"; $previousLineIndented = false; @@ -1054,16 +1028,6 @@ class Parser return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- '); } - /** - * Tests whether or not the current line is the header of a block scalar. - * - * @return bool - */ - private function isBlockScalarHeader() - { - return (bool) self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine); - } - /** * A local wrapper for `preg_match` which will throw a ParseException if there * is an internal error in the PCRE engine.