Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Parse/Processor/Symfony3Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
11 changes: 11 additions & 0 deletions tests/Parse/YamlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/yaml/symfony3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the above but also just a single quote? Complex2 would pass without being modified because it's a quoted value in it's entirety, and middle would pass because the value would be wrapped in single quotes, but I'm wondering about middeSingle: this string has some single quote's, and maybe a 'air quote', anything to make your life diff'cult

testComment:
key: value
#comment: comments should be removed