Skip to content

Commit 6e66c5b

Browse files
Merge branch '6.0' into 6.1
* 6.0: (27 commits) [DoctrineBridge] fix tests [HttpKernel] Fix session test cases for symfony [FrameworkBundle] Fix missing arguments when a serialization default context is bound [Runtime] Fix --env and --no-debug with dotenv_overload [Cache] fix merge cs fix [Finder] Fix finding VCS re-included files in excluded directory [Yaml] Improve the deprecation warnings for octal numbers to suggest migrating Fix Choice constraint with associative choices array [Form] UrlType should not add protocol to emails [Dotenv] Fix bootEnv() override with .env.local.php when the env key already exists Silence isatty warnings during tty detection [Serializer] Fix AbstractObjectNormalizer not considering pseudo type false [Notifier] Fix encoding of messages with FreeMobileTransport [Cache] workaround PHP crash [Console] Fix PHP 8.1 deprecation in ChoiceQuestion [HttpKernel] Fix compatibility with php bridge and already started php sessions [Notifier] smsapi-notifier - correct encoding Replaced full CoC text with link to documentation Making the parser stateless ...
2 parents 6e54cff + e77f3ea commit 6e66c5b

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Inline.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,21 +628,18 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
628628
return (float) substr($scalar, 8);
629629
case str_starts_with($scalar, '!!binary '):
630630
return self::evaluateBinaryScalar(substr($scalar, 9));
631-
default:
632-
throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
633631
}
634-
// no break
632+
633+
throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
635634
case preg_match('/^(?:\+|-)?0o(?P<value>[0-7_]++)$/', $scalar, $matches):
636635
$value = str_replace('_', '', $matches['value']);
637636

638637
if ('-' === $scalar[0]) {
639638
return -octdec($value);
640-
} else {
641-
return octdec($value);
642639
}
643640

641+
return octdec($value);
644642
// Optimize for returning strings.
645-
// no break
646643
case \in_array($scalar[0], ['+', '-', '.'], true) || is_numeric($scalar[0]):
647644
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
648645
$scalar = str_replace('_', '', $scalar);

Parser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public function parse(string $value, int $flags = 0): mixed
8585
try {
8686
$data = $this->doParse($value, $flags);
8787
} finally {
88+
$this->refsBeingParsed = [];
89+
$this->offset = 0;
8890
$this->lines = [];
8991
$this->currentLine = '';
9092
$this->numberOfParsedLines = 0;

Tests/ParserTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ public function invalidIndentation(): array
8484
];
8585
}
8686

87+
public function testParserIsStateless()
88+
{
89+
$yamlString = '# translations/messages.en.yaml
90+
91+
';
92+
$this->parser->parse($yamlString);
93+
$this->parser->parse($yamlString);
94+
95+
$this->expectException(ParseException::class);
96+
$this->expectExceptionMessage("A YAML file cannot contain tabs as indentation at line 2 (near \"\tabc\")");
97+
98+
$this->parser->parse("abc:\n\tabc");
99+
}
100+
87101
/**
88102
* @dataProvider validTokenSeparators
89103
*/

0 commit comments

Comments
 (0)