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

Commits on Jan 20, 2018

  1. Copy the full SHA
    049b49a View commit details
  2. Copy the full SHA
    af61597 View commit details

Commits on Jan 21, 2018

  1. Merge branch '3.3' into 3.4

    * 3.3:
      Have weak_vendors ignore deprecations from outside
      [HttpFoundation] fixed return type of method HeaderBag::get
      [HttpFoundation] Added "resource" type on Request::create docblock
      [Process] Skip environment variables with false value in Process
      Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
      Formatting fix in upgrade 3.0 document
      don't split lines on carriage returns when dumping
      Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
      [DI] compilation perf tweak
      [Validator] Conflict with egulias/email-validator 2.0
      [Validator] add missing parent isset and add test
    nicolas-grekas committed Jan 21, 2018
    Copy the full SHA
    eab73b6 View commit details
  2. Merge branch '3.4' into 4.0

    * 3.4:
      Have weak_vendors ignore deprecations from outside
      [HttpFoundation] fixed return type of method HeaderBag::get
      [HttpFoundation] Added "resource" type on Request::create docblock
      [Process] Skip environment variables with false value in Process
      Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
      Formatting fix in upgrade 3.0 document
      don't split lines on carriage returns when dumping
      Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
      [DI] compilation perf tweak
      [Validator] Conflict with egulias/email-validator 2.0
      [Validator] add missing parent isset and add test
    nicolas-grekas committed Jan 21, 2018
    Copy the full SHA
    ffc60bd View commit details
Showing with 18 additions and 6 deletions.
  1. +1 −1 Dumper.php
  2. +1 −0 Inline.php
  3. +7 −1 Tests/DumperTest.php
  4. +1 −0 Tests/Fixtures/multiple_lines_as_literal_block.yml
  5. +4 −4 Tests/InlineTest.php
  6. +4 −0 Tests/ParserTest.php
2 changes: 1 addition & 1 deletion Dumper.php
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
$dumpAsMap = Inline::isHash($input);

foreach ($input as $key => $value) {
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) {
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
$output .= sprintf("%s%s%s |\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '');

foreach (preg_split('/\n|\r\n/', $value) as $row) {
1 change: 1 addition & 0 deletions Inline.php
Original file line number Diff line number Diff line change
@@ -286,6 +286,7 @@ public static function parseScalar(string $scalar, int $flags = 0, array $delimi
} elseif (Parser::preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
$output = $match[1];
$i += strlen($output);
$output = trim($output);
} else {
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}
8 changes: 7 additions & 1 deletion Tests/DumperTest.php
Original file line number Diff line number Diff line change
@@ -377,7 +377,8 @@ public function testDumpMultiLineStringAsScalarBlock()
$data = array(
'data' => array(
'single_line' => 'foo bar baz',
'multi_line' => "foo\nline with trailing spaces:\n \nbar\r\ninteger like line:\n123456789\nempty line:\n\nbaz",
'multi_line' => "foo\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz",
'multi_line_with_carriage_return' => "foo\nbar\r\nbaz",
'nested_inlined_multi_line_string' => array(
'inlined_multi_line' => "foo\nbar\r\nempty line:\n\nbaz",
),
@@ -387,6 +388,11 @@ public function testDumpMultiLineStringAsScalarBlock()
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
}

public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
{
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
1 change: 1 addition & 0 deletions Tests/Fixtures/multiple_lines_as_literal_block.yml
Original file line number Diff line number Diff line change
@@ -10,4 +10,5 @@ data:
empty line:
baz
multi_line_with_carriage_return: "foo\nbar\r\nbaz"
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
8 changes: 4 additions & 4 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
@@ -252,9 +252,9 @@ public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
{
if (method_exists($this, 'expectExceptionMessage')) {
$this->expectException(ParseException::class);
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
} else {
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
}

Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
@@ -272,9 +272,9 @@ public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
{
if (method_exists($this, 'expectExceptionMessage')) {
$this->expectException(ParseException::class);
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
} else {
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
}

Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
4 changes: 4 additions & 0 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
@@ -1602,6 +1602,10 @@ public function taggedValuesProvider()
- !quz {foo: bar, quz: !bar {one: bar}}
YAML
),
'spaces-around-tag-value-in-sequence' => array(
array(new TaggedValue('foo', 'bar')),
'[ !foo bar ]',
),
);
}