Skip to content

Commit c441e9d

Browse files
Merge branch '4.4' into 5.3
* 4.4: [Cache] workaround PHP crash [Console] Fix PHP 8.1 deprecation in ChoiceQuestion Making the parser stateless
2 parents 32e33ce + d7f637c commit c441e9d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Parser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public function parse(string $value, int $flags = 0)
9999
if (null !== $mbEncoding) {
100100
mb_internal_encoding($mbEncoding);
101101
}
102+
$this->refsBeingParsed = [];
103+
$this->offset = 0;
102104
$this->lines = [];
103105
$this->currentLine = '';
104106
$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)