diff --git a/src/Symfony/Component/Yaml/Escaper.php b/src/Symfony/Component/Yaml/Escaper.php index f77545db95632..7409ebfe2c366 100644 --- a/src/Symfony/Component/Yaml/Escaper.php +++ b/src/Symfony/Component/Yaml/Escaper.php @@ -71,7 +71,7 @@ public static function escapeWithDoubleQuotes($value) */ public static function requiresSingleQuoting($value) { - return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value); + return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value); } /** diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 04e9d4df80985..dc8ab7061b9e4 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Yaml\Tests; -use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Inline; class InlineTest extends \PHPUnit_Framework_TestCase @@ -31,11 +30,11 @@ public function testDump() $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); } - foreach ($this->getTestsForParse() as $yaml => $value) { + foreach ($this->getTestsForParse() as $value) { $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } - foreach ($testsForDump as $yaml => $value) { + foreach ($testsForDump as $value) { $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } } @@ -205,6 +204,9 @@ protected function getTestsForDump() "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', + "'-dash'" => '-dash', + "'-'" => '-', + // sequences '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),