Skip to content

Commit d76b754

Browse files
committed
Merge branch 'hotfix/v1.1.1'
2 parents f1305dd + 8e73337 commit d76b754

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Util/StringLiteralFormatter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class StringLiteralFormatter
1919
public static function formatValueForRHS($value): string
2020
{
2121
if (is_string($value)) {
22+
$value = str_replace('"', '\"', $value);
2223
$value = "\"$value\"";
2324
} elseif (is_bool($value)) {
2425
if ($value) {

tests/StringLiteralFormatterTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ public function testFormatForClassRHSValue()
2828
$formattedString = StringLiteralFormatter::formatValueForRHS('someString');
2929
$this->assertEquals('"someString"', $formattedString);
3030

31+
$formattedString = StringLiteralFormatter::formatValueForRHS('"quotedString"');
32+
$this->assertEquals('"\"quotedString\""', $formattedString);
33+
34+
$formattedString = StringLiteralFormatter::formatValueForRHS("\"quotedString\"");
35+
$this->assertEquals('"\"quotedString\""', $formattedString);
36+
37+
$formattedString = StringLiteralFormatter::formatValueForRHS('\'singleQuotes\'');
38+
$this->assertEquals('"\'singleQuotes\'"', $formattedString);
39+
3140
// Integer tests
3241
$integerString = StringLiteralFormatter::formatValueForRHS(25);
3342
$this->assertEquals('25', $integerString);

0 commit comments

Comments
 (0)