diff --git a/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php b/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php index 13c92f56..904c2b7e 100644 --- a/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php +++ b/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php @@ -65,7 +65,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void } // remove ones not having type at the beginning - self::removeVarAnnotationNotMatchingPattern($tokens, $index, '/@var\\s+[\\?\\\\a-zA-Z_\\x7f-\\xff]/'); + self::removeVarAnnotationNotMatchingPattern($tokens, $index, '/@var\\s+[\\?\\\\a-zA-Z_\\x7f-\\xff\'"]/'); $nextIndex = self::getIndexAfterPhpDoc($tokens, $index); diff --git a/tests/Fixer/PhpdocNoIncorrectVarAnnotationFixerTest.php b/tests/Fixer/PhpdocNoIncorrectVarAnnotationFixerTest.php index 854877b5..5b68b149 100644 --- a/tests/Fixer/PhpdocNoIncorrectVarAnnotationFixerTest.php +++ b/tests/Fixer/PhpdocNoIncorrectVarAnnotationFixerTest.php @@ -257,6 +257,33 @@ class Foo }', ]; + yield 'keep string literals' => [ + <<<'PHP' + [ '