8000 Merge branch '5.3' into 5.4 · symfony/symfony@f218720 · GitHub
[go: up one dir, main page]

Skip to content

Commit f218720

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: Fix nullable parameter doc don't try to replace references in quoted strings
2 parents e227a52 + d408428 commit f218720

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(string $format = 'P%yY%mM%dDT%hH%iM%sS')
3939
/**
4040
* Transforms a DateInterval object into a date string with the configured format.
4141
*
42-
* @param \DateInterval $value A DateInterval object
42+
* @param \DateInterval|null $value A DateInterval object
4343
*
4444
* @return string
4545
*

src/Symfony/Component/Yaml/Inline.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,
389389
}
390390
}
391391

392-
if (\is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
392+
if (!$isQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
393393
$references[$matches['ref']] = $matches['value'];
394394
$value = $matches['value'];
395395
}
@@ -523,6 +523,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
523523
}
524524
break;
525525
default:
526+
$isValueQuoted = \in_array($mapping[$i], ['"', "'"]);
526527
$value = self::parseScalar($mapping, $flags, [',', '}', "\n"], $i, null === $tag, $references);
527528
// Spec: Keys MUST be unique; first one wins.
528529
// Parser cannot abort this mapping earlier, since lines
@@ -531,7 +532,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
531532
if ('<<' === $key) {
532533
$output += $value;
533534
} elseif ($allowOverwrite || !isset($output[$key])) {
534-
if (\is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
535+
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
535536
$references[$matches['ref']] = $matches['value'];
536537
$value = $matches['value'];
537538
}

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,4 +945,22 @@ public function ideographicSpaceProvider(): array
945945
["'a b'", 'a b'],
946946
];
947947
}
948+
949+
public function testParseQuotedReferenceLikeStringsInMapping()
950+
{
951+
$yaml = <<<YAML
952+
{foo: '&foo', bar: "&bar"}
953+
YAML;
954+
955+
$this->assertSame(['foo' => '&foo', 'bar' => '&bar'], Inline::parse($yaml));
956+
}
957+
958+
public function testParseQuotedReferenceLikeStringsInSequence()
959+
{
960+
$yaml = <<<YAML
961+
['&foo', "&bar" ]
962+
YAML;
963+
964+
$this->assertSame(['&foo', '&bar'], Inline::parse($yaml));
965+
}
948966
}

0 commit comments

Comments
 (0)
0