Skip to content

Commit ba539ca

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Validator] added magic method __isset() to File Constraint class [DI] Fix possible incorrect php-code when dumped strings contains newlines [Translation] minor: remove unused variable in test never match invalid IP addresses
2 parents a717286 + a09175a commit ba539ca

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Dumper/PhpDumper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,13 @@ private function export($value)
15871587
return $dirname;
15881588
}
15891589

1590+
if (is_string($value) && false !== strpos($value, "\n")) {
1591+
$cleanParts = explode("\n", $value);
1592+
$cleanParts = array_map(function ($part) { return var_export($part, true); }, $cleanParts);
1593+
1594+
return implode('."\n".', $cleanParts);
1595+
}
1596+
15901597
return var_export($value, true);
15911598
}
15921599
}

Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function testDumpOptimizationString()
5555
'optimize concatenation with empty string' => 'string1%empty_value%string2',
5656
'optimize concatenation from the start' => '%empty_value%start',
5757
'optimize concatenation at the end' => 'end%empty_value%',
58+
'new line' => "string with \nnew line",
5859
));
5960

6061
$container = new ContainerBuilder();

Tests/Fixtures/php/services10.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function isFrozen()
5656
*/
5757
protected function getTestService()
5858
{
59-
return $this->services['test'] = new \stdClass(array('only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end'));
59+
return $this->services['test'] = new \stdClass(array('only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end', 'new line' => 'string with '."\n".'new line'));
6060
}
6161

6262
/**

0 commit comments

Comments
 (0)