Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/yaml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.3.4
Choose a base ref
...
head repository: symfony/yaml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.3.5
Choose a head ref
  • 6 commits
  • 4 files changed
  • 3 contributors

Commits on Aug 29, 2019

  1. Copy the full SHA
    717182d View commit details

Commits on Aug 30, 2019

  1. Merge branch '3.4' into 4.3

    * 3.4:
      Return null as Expire header if it was set to null
      [ProxyManager] remove ProxiedMethodReturnExpression polyfill
      fix dumping not inlined scalar tag values
    nicolas-grekas committed Aug 30, 2019
    Copy the full SHA
    9973789 View commit details

Commits on Sep 10, 2019

  1. Copy the full SHA
    768f817 View commit details
  2. Merge branch '3.4' into 4.3

    * 3.4:
      Update GitHub PR template
      don't dump a scalar tag value on its own line
    nicolas-grekas committed Sep 10, 2019
    Copy the full SHA
    24075a7 View commit details

Commits on Sep 11, 2019

  1. Copy the full SHA
    2d43e0d View commit details
  2. bug #33517 [Yaml] properly catch legacy tag syntax usages (xabbuh)

    This PR was merged into the 4.3 branch.
    
    Discussion
    ----------
    
    [Yaml] properly catch legacy tag syntax usages
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 4.3
    | Bug fix?      | yes
    | New feature?  | no
    | BC breaks?    | no
    | Deprecations? | no
    | Tests pass?   | yes
    | Fixed tickets | #25534
    | License       | MIT
    | Doc PR        |
    
    Commits
    -------
    
    d5894a4ff9 properly catch legacy tag syntax usages
    fabpot committed Sep 11, 2019
    Copy the full SHA
    41e1635 View commit details
Showing with 44 additions and 3 deletions.
  1. +1 −1 Dumper.php
  2. +6 −2 Inline.php
  3. +28 −0 Tests/DumperTest.php
  4. +9 −0 Tests/ParserTest.php
2 changes: 1 addition & 1 deletion Dumper.php
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
if ($value instanceof TaggedValue) {
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());

if ($inline - 1 <= 0) {
if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) {
$output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
} else {
$output .= "\n";
8 changes: 6 additions & 2 deletions Inline.php
Original file line number Diff line number Diff line change
@@ -670,18 +670,22 @@ private static function parseTag(string $value, int &$i, int $flags): ?string
$nextOffset += strspn($value, ' ', $nextOffset);

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

$i = $nextOffset;

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

if ('' !== $tag && !isset($value[$i])) {
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}

if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
return $tag;
}
28 changes: 28 additions & 0 deletions Tests/DumperTest.php
Original file line number Diff line number Diff line change
@@ -459,6 +459,34 @@ public function testDumpingTaggedValueMapWithInlinedTagValues()
$this->assertSame($expected, $yaml);
}

public function testDumpingNotInlinedScalarTaggedValue()
{
$data = [
'user1' => new TaggedValue('user', 'jane'),
'user2' => new TaggedValue('user', 'john'),
];
$expected = <<<YAML
user1: !user jane
user2: !user john
YAML;

$this->assertSame($expected, $this->dumper->dump($data, 2));
}

public function testDumpingNotInlinedNullTaggedValue()
{
$data = [
'foo' => new TaggedValue('bar', null),
];
$expected = <<<YAML
foo: !bar null
YAML;

$this->assertSame($expected, $this->dumper->dump($data, 2));
}

public function testDumpMultiLineStringAsScalarBlock()
{
$data = [
9 changes: 9 additions & 0 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
namespace Symfony\Component\Yaml\Tests;

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

public function testDeprecatedPhpConstantSyntax()
{
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Missing value for tag "php/const:App\Kernel::SEMART_VERSION" at line 1 (near "!php/const:App\Kernel::SEMART_VERSION").');

$this->parser->parse('!php/const:App\Kernel::SEMART_VERSION', Yaml::PARSE_CUSTOM_TAGS | Yaml::PARSE_CONSTANT);
}

public function testMergeKeysWhenMappingsAreParsedAsObjects()
{
$yaml = <<<YAML