diff --git a/src/Parse/Processor/Symfony3Processor.php b/src/Parse/Processor/Symfony3Processor.php index 8eed335a9..bc9085db7 100644 --- a/src/Parse/Processor/Symfony3Processor.php +++ b/src/Parse/Processor/Symfony3Processor.php @@ -21,8 +21,8 @@ public function preprocess($text) foreach ($lines as &$line) { // Surround array keys with quotes if not already - $line = preg_replace_callback('/^( *)([\'"]{0}[^\'"\n\r:]+[\'"]{0})\s*:/m', function ($matches) { - return $matches[1] . '"' . trim($matches[2]) . '":'; + $line = preg_replace_callback('/^( *)([\'"]{0}[^\'"\n\r:#]+[\'"]{0})\s*:/m', function ($matches) { + return $matches[1] . "'" . trim($matches[2]) . "':"; }, rtrim($line)); } diff --git a/tests/Parse/YamlTest.php b/tests/Parse/YamlTest.php index 098af0b43..0e5d63bfc 100644 --- a/tests/Parse/YamlTest.php +++ b/tests/Parse/YamlTest.php @@ -144,6 +144,17 @@ public function testSymfony3YamlFileWithProcessor() 'false' => false, ], ], + 'testClass' => [ + 'My\Class\Path' => 'value' + ], + 'testQuoting' => [ + 'complex1' => 'this is "very" complex quoting', + 'complex2' => 'this is also \'very\' complex quoting', + 'middle' => 'this string is "quoted" in the middle', + ], + 'testComment' => [ + 'key' => 'value', + ], ], ], ], $yaml); diff --git a/tests/fixtures/yaml/symfony3.yaml b/tests/fixtures/yaml/symfony3.yaml index a51719f6d..98cd26cde 100644 --- a/tests/fixtures/yaml/symfony3.yaml +++ b/tests/fixtures/yaml/symfony3.yaml @@ -29,3 +29,13 @@ form: options: true: true false: false + testClass: + My\Class\Path: value + testQuoting: + complex1: 'this is "very" complex quoting' + complex2: "this is also 'very' complex quoting" + middle: this string is "quoted" in the middle + testComment: + key: value + #comment: comments should be removed +