Skip to content

Commit 564b63f

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: fixed "link" to Contracts packages [WebProfilerBundle] Fix time panel legend buttons Fixed cache pools affecting each other due to an overwritten seed variable properly catch legacy tag syntax usages
2 parents 40ff940 + 41e1635 commit 564b63f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Inline.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,18 +674,22 @@ private static function parseTag(string $value, int &$i, int $flags): ?string
674674
$nextOffset += strspn($value, ' ', $nextOffset);
675675

676676
// Is followed by a scalar and is a built-in tag
677-
if ($tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
677+
if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
678678
// Manage in {@link self::evaluateScalar()}
679679
return null;
680680
}
681681

682682
$i = $nextOffset;
683683

684684
// Built-in tags
685-
if ($tag && '!' === $tag[0]) {
685+
if ('' !== $tag && '!' === $tag[0]) {
686686
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
687687
}
688688

689+
if ('' !== $tag && !isset($value[$i])) {
690+
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
691+
}
692+
689693
if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
690694
return $tag;
691695
}

Tests/ParserTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Yaml\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Yaml\Exception\ParseException;
1516
use Symfony\Component\Yaml\Parser;
1617
use Symfony\Component\Yaml\Tag\TaggedValue;
1718
use Symfony\Component\Yaml\Yaml;
@@ -1841,6 +1842,14 @@ public function testPhpConstantTagMappingKey()
18411842
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
18421843
}
18431844

1845+
public function testDeprecatedPhpConstantSyntax()
1846+
{
1847+
$this->expectException(ParseException::class);
1848+
$this->expectExceptionMessage('Missing value for tag "php/const:App\Kernel::SEMART_VERSION" at line 1 (near "!php/const:App\Kernel::SEMART_VERSION").');
1849+
1850+
$this->parser->parse('!php/const:App\Kernel::SEMART_VERSION', Yaml::PARSE_CUSTOM_TAGS | Yaml::PARSE_CONSTANT);
1851+
}
1852+
18441853
public function testMergeKeysWhenMappingsAreParsedAsObjects()
18451854
{
18461855
$yaml = <<<YAML

0 commit comments

Comments
 (0)