Skip to content
/ yaml Public
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.0.1
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.0.2
Choose a head ref
  • 10 commits
  • 4 files changed
  • 4 contributors

Commits on Dec 5, 2017

  1. do not evaluate PHP constant names

    PHP constant identifiers must be strings anyway. Thus, we only need to
    parse quoted strings, but do not have to evaluate the data types.
    xabbuh committed Dec 5, 2017
    Copy the full SHA
    7c97fe6 View commit details

Commits on Dec 8, 2017

  1. fix some edge cases with indented blocks

    Now that comment-like lines are no longer ignored when subparsers are
    created, we need to ignore them in some functions (e.g. when detecting
    the indentation depth of the next block).
    xabbuh committed Dec 8, 2017
    Copy the full SHA
    8c26ed8 View commit details
  2. Copy the full SHA
    08b69a6 View commit details
  3. Merge branch '3.3' into 3.4

    * 3.3: (21 commits)
      [appveyor] disable memory limit on composer up
      Remove some unused variables and properties
      Remove some unused variables, properties and methods
      fix some edge cases with indented blocks
      [ExpressionLanguage] Fix parse error on 5.3
      [HttpKernel] remove noisy frame in controller stack traces
      [DI] Fix circular-aliases message
      [ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice
      Prevent a loop in aliases within the `findDefinition` method
      Fix php doc in Table class
      bumped Symfony version to 3.3.15
      updated VERSION for 3.3.14
      updated CHANGELOG for 3.3.14
      bumped Symfony version to 2.8.33
      updated VERSION for 2.8.32
      updated CHANGELOG for 2.8.32
      bumped Symfony version to 2.7.40
      updated VERSION for 2.7.39
      update CONTRIBUTORS for 2.7.39
      updated CHANGELOG for 2.7.39
      ...
    nicolas-grekas committed Dec 8, 2017
    Copy the full SHA
    be35993 View commit details
  4. minor #25402 Remove some unused variables and properties (tgalopin)

    This PR was merged into the 3.4 branch.
    
    Discussion
    ----------
    
    Remove some unused variables and properties
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 3.4
    | Bug fix?      | yes
    | New feature?  | no
    | BC breaks?    | no
    | Deprecations? | no
    | Tests pass?   | yes
    | Fixed tickets | -
    | License       | MIT
    
    Analyzing symfony/symfony using https://insight.sensiolabs.com, I found several chunks of dead code. This PR removes them in the 3.4 branch.
    
    Commits
    -------
    
    ec92d9b Remove some unused variables and properties
    nicolas-grekas committed Dec 8, 2017
    Copy the full SHA
    5009c3e View commit details
  5. Merge branch '3.4' into 4.0

    * 3.4: (37 commits)
      Remove some unused variables and properties
      [appveyor] disable memory limit on composer up
      [HttpFoundation] don't prefix cookies with "Set-Cookie:"
      Remove some unused variables and properties
      Fix debug:form definition
      Remove some unused variables, properties and methods
      fix some edge cases with indented blocks
      [ExpressionLanguage] Fix parse error on 5.3
      [HttpKernel] remove noisy frame in controller stack traces
      [DI] Force root-namespace for function calls in the dumper container
      [DI] Fix circular-aliases message
      register system cache clearer only if it's used
      doc : Namespace prefix must end with a "\"
      [ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice
      Prevent a loop in aliases within the `findDefinition` method
      [HttpKernel] Disable inlining on PHP 5
      Ensure that inlined services with parameterized class name can be dumped
      [DI] Fix non-string class handling in PhpDumper
      Throw a sensible exception when controller has been removed
      Remove LOCK_EX That Breaks Cache Usage on NFS
      ...
    nicolas-grekas committed Dec 8, 2017
    Copy the full SHA
    aeb0ee7 View commit details
  6. fix merge

    nicolas-grekas committed Dec 8, 2017
    Copy the full SHA
    73afed1 View commit details

Commits on Dec 11, 2017

  1. Copy the full SHA
    778b433 View commit details
  2. Merge branch '3.3' into 3.4

    * 3.3:
      Tweaking class not found autowiring error
      [TwigBridge] Add missing dev requirement for workflow
      fixed #25440
      empty lines don't count for indent detection
    fabpot committed Dec 11, 2017
    Copy the full SHA
    afe0cd3 View commit details

Commits on Dec 12, 2017

  1. Merge branch '3.4' into 4.0

    * 3.4: (22 commits)
      fix merge
      [Translation] Fix InvalidArgumentException when using untranslated plural forms from .po files
      Fixed exit code with non-integer throwable code
      [HttpFoundation] Support 0 bit netmask in IPv6 ()
      [DI] Impossible to set an environment variable and then an array as container parameter
      [Process] remove false-positive BC breaking exception on Windows
      Tweaking class not found autowiring error
      [LDAP] added missing dots at the end of some exception messages.
      [TwigBridge] Add missing dev requirement for workflow
      fixed #25440
      empty lines don't count for indent detection
      Set `width: auto` on WebProfiler toolbar's reset.
      [Lock] Fix incorrect phpdoc
      [Process] Dont rely on putenv(), it fails on ZTS PHP
      [HttpKernel] detect deprecations thrown by container initialization during tests
      [HttpKernel] Fix logging of post-terminate errors/exceptions
      [DI] Add context to service-not-found exceptions thrown by service locators
      [Debug] Fix catching fatal errors in case of nested error handlers
      [VarDumper] Fixed file links leave blank pages when ide is configured
      Fix hidden currency element with Bootstrap 3 theme
      ...
    nicolas-grekas committed Dec 12, 2017
    Copy the full SHA
    a5ee52d View commit details
Showing with 122 additions and 12 deletions.
  1. +2 −1 Inline.php
  2. +45 −11 Parser.php
  3. +1 −0 Tests/InlineTest.php
  4. +74 −0 Tests/ParserTest.php
3 changes: 2 additions & 1 deletion Inline.php
Original file line number Diff line number Diff line change
@@ -583,7 +583,8 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
return;
case 0 === strpos($scalar, '!php/const'):
if (self::$constantSupport) {
if (defined($const = self::parseScalar(substr($scalar, 11)))) {
$i = 0;
if (defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
return constant($const);
}

56 changes: 45 additions & 11 deletions Parser.php
Original file line number Diff line number Diff line change
@@ -521,7 +521,27 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
}

if (null === $indentation) {
$newIndent = $this->getCurrentLineIndentation();
$newIndent = null;
$movements = 0;

do {
$EOF = false;

// empty and comment-like lines do not influence the indentation depth
if ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$EOF = !$this->moveToNextLine();

if (!$EOF) {
++$movements;
}
} else {
$newIndent = $this->getCurrentLineIndentation();
}
} while (!$EOF && null === $newIndent);

for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}

$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();

@@ -535,6 +555,8 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
$data = array();
if ($this->getCurrentLineIndentation() >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent);
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$data[] = $this->currentLine;
} else {
$this->moveToPreviousLine();

@@ -851,19 +873,25 @@ private function parseBlockScalar(string $style, string $chomping = '', int $ind
private function isNextLineIndented(): bool
{
$currentIndentation = $this->getCurrentLineIndentation();
$EOF = !$this->moveToNextLine();
$movements = 0;

while (!$EOF && $this->isCurrentLineEmpty()) {
do {
$EOF = !$this->moveToNextLine();
}

if (!$EOF) {
++$movements;
}
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));

if ($EOF) {
return false;
}

$ret = $this->getCurrentLineIndentation() > $currentIndentation;

$this->moveToPreviousLine();
for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}

return $ret;
}
@@ -952,19 +980,25 @@ private function cleanup(string $value): string
private function isNextLineUnIndentedCollection(): bool
{
$currentIndentation = $this->getCurrentLineIndentation();
$notEOF = $this->moveToNextLine();
$movements = 0;

while ($notEOF && $this->isCurrentLineEmpty()) {
$notEOF = $this->moveToNextLine();
}
do {
$EOF = !$this->moveToNextLine();

if (!$EOF) {
++$movements;
}
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));

if (false === $notEOF) {
if ($EOF) {
return false;
}

$ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem();

$this->moveToPreviousLine();
for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}

return $ret;
}
1 change: 1 addition & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ public function getTestsForParsePhpConstants()
array('!php/const PHP_INT_MAX', PHP_INT_MAX),
array('[!php/const PHP_INT_MAX]', array(PHP_INT_MAX)),
array('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
array('!php/const NULL', null),
);
}

74 changes: 74 additions & 0 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
@@ -1932,6 +1932,80 @@ public function testEvalRefException()
EOE;
$this->parser->parse($yaml);
}

/**
* @dataProvider indentedMappingData
*/
public function testParseIndentedMappings($yaml, $expected)
{
$this->assertSame($expected, $this->parser->parse($yaml));
}

public function indentedMappingData()
{
$tests = array();

$yaml = <<<YAML
foo:
- bar: "foobar"
# A comment
baz: "foobaz"
YAML;
$expected = array(
'foo' => array(
array(
'bar' => 'foobar',
'baz' => 'foobaz',
),
),
);
$tests['comment line is first line in indented block'] = array($yaml, $expected);

$yaml = <<<YAML
foo:
- bar:
# comment
baz: [1, 2, 3]
YAML;
$expected = array(
'foo' => array(
array(
'bar' => array(
'baz' => array(1, 2, 3),
),
),
),
);
$tests['mapping value on new line starting with a comment line'] = array($yaml, $expected);

$yaml = <<<YAML
foo:
-
bar: foobar
YAML;
$expected = array(
'foo' => array(
array(
'bar' => 'foobar',
),
),
);
$tests['mapping in sequence starting on a new line'] = array($yaml, $expected);

$yaml = <<<YAML
foo:
bar: baz
YAML;
$expected = array(
'foo' => array(
'bar' => 'baz',
),
);
$tests['blank line at the beginning of an indented mapping value'] = array($yaml, $expected);

return $tests;
}
}

class B