Skip to content

Commit e77f3ea

Browse files
Merge branch '5.4' into 6.0
* 5.4: (21 commits) [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 [Console] fix restoring stty mode on CTRL+C fix merge (bis) fix merge [Process] Avoid calling fclose on an already closed resource [GHA] test tty group [DI] Fix tests on PHP 7.1 ...
2 parents fa3be9d + e80f87d commit e77f3ea

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
@@ -620,21 +620,18 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
620620
return (float) substr($scalar, 8);
621621
case 0 === strpos($scalar, '!!binary '):
622622
return self::evaluateBinaryScalar(substr($scalar, 9));
623-
default:
624-
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);
625623
}
626-
// no break
624+
625+
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);
627626
case preg_match('/^(?:\+|-)?0o(?P<value>[0-7_]++)$/', $scalar, $matches):
628627
$value = str_replace('_', '', $matches['value']);
629628

630629
if ('-' === $scalar[0]) {
631630
return -octdec($value);
632-
} else {
633-
return octdec($value);
634631
}
635632

633+
return octdec($value);
636634
// Optimize for returning strings.
637-
// no break
638635
case \in_array($scalar[0], ['+', '-', '.'], true) || is_numeric($scalar[0]):
639636
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
640637
$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)