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.4.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.4.5
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Jan 16, 2020

  1. Copy the full SHA
    bc63e15 View commit details

Commits on Feb 3, 2020

  1. Merge branch '3.4' into 4.4

    * 3.4:
      [Phpunit] Fix running skipped tests expecting only deprecations
      [DependencyInjection] #35505 Fix typo in test name
      [Yaml][Inline] Fail properly on empty object tag and empty const tag
      Check non-null type for numeric type
      Check value isset to avoid PHP notice
      bug symfony#28179 [DomCrawler] Skip disabled fields processing in Form
    nicolas-grekas committed Feb 3, 2020
    Copy the full SHA
    94d005c View commit details
Showing with 51 additions and 0 deletions.
  1. +8 −0 Inline.php
  2. +43 −0 Tests/InlineTest.php
8 changes: 8 additions & 0 deletions Inline.php
Original file line number Diff line number Diff line change
@@ -589,6 +589,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
return substr($scalar, 2);
case 0 === strpos($scalar, '!php/object'):
if (self::$objectSupport) {
if (!isset($scalar[12])) {
return false;
}

return unserialize(self::parseScalar(substr($scalar, 12)));
}

@@ -599,6 +603,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
return null;
case 0 === strpos($scalar, '!php/const'):
if (self::$constantSupport) {
if (!isset($scalar[11])) {
return '';
}

$i = 0;
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
return \constant($const);
43 changes: 43 additions & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
@@ -738,6 +738,49 @@ public function getTestsForOctalNumbers()
];
}

/**
* @dataProvider phpObjectTagWithEmptyValueProvider
*/
public function testPhpObjectWithEmptyValue($expected, $value)
{
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT));
}

public function phpObjectTagWithEmptyValueProvider()
{
return [
[false, '!php/object'],
[false, '!php/object '],
[false, '!php/object '],
[[false], '[!php/object]'],
[[false], '[!php/object ]'],
[[false, 'foo'], '[!php/object , foo]'],
];
}

/**
* @dataProvider phpConstTagWithEmptyValueProvider
*/
public function testPhpConstTagWithEmptyValue($expected, $value)
{
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT));
}

public function phpConstTagWithEmptyValueProvider()
{
return [
['', '!php/const'],
['', '!php/const '],
['', '!php/const '],
[[''], '[!php/const]'],
[[''], '[!php/const ]'],
[['', 'foo'], '[!php/const , foo]'],
[['' => 'foo'], '{!php/const: foo}'],
[['' => 'foo'], '{!php/const : foo}'],
[['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'],
];
}

/**
* @dataProvider unquotedExclamationMarkThrowsProvider
*/