diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index 3dcaec4f24..c1369aa664 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -123,6 +123,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->beginChangeset(); $innerContent = substr($workingString, 1, -1); $innerContent = str_replace('\"', '"', $innerContent); + $innerContent = str_replace('\\$', '$', $innerContent); $phpcsFile->fixer->replaceToken($stackPtr, "'$innerContent'"); while ($lastStringToken !== $stackPtr) { $phpcsFile->fixer->replaceToken($lastStringToken, ''); diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc index 2efd419b14..d0b22ceba4 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc @@ -14,6 +14,7 @@ $string = 'Hello '.$there.' Greg'; $string = "
"; $string = "Value: $var[test]"; $string = "\0"; +$string = "\$var"; $x = "bar = '$z', baz = '" . $a . "'...$x"; diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc.fixed index 563fdd87d9..fb142e54ab 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc.fixed @@ -14,6 +14,7 @@ $string = 'Hello '.$there.' Greg'; $string = "
"; $string = "Value: $var[test]"; $string = "\0"; +$string = '$var'; $x = "bar = '$z', baz = '" . $a . "'...$x"; diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php index 42017bc6b6..83036db769 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php @@ -32,11 +32,12 @@ public function getErrorList() 8 => 2, 14 => 1, 15 => 1, - 18 => 1, + 17 => 1, 19 => 1, - 21 => 1, - 28 => 1, + 20 => 1, + 22 => 1, 29 => 1, + 30 => 1, ); }//end getErrorList()