diff --git a/src/Lexer.php b/src/Lexer.php index 78b07156506..28feaa2c128 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -418,7 +418,7 @@ private function stripcslashes(string $str, string $quoteType): string $result .= $nextChar; } elseif ("'" === $nextChar || '"' === $nextChar) { if ($nextChar !== $quoteType) { - trigger_deprecation('twig/twig', '3.12', 'Character "%s" at position %d does not need to be escaped anymore.', $nextChar, $i + 1); + trigger_deprecation('twig/twig', '3.12', 'Character "%s" at position %d should not be escaped; the "\" character is ignored in Twig v3 but will not be in v4. Please remove the extra "\" character.', $nextChar, $i + 1); } $result .= $nextChar; } elseif ('#' === $nextChar && $i + 1 < $length && '{' === $str[$i + 1]) { @@ -437,7 +437,7 @@ private function stripcslashes(string $str, string $quoteType): string } $result .= \chr(octdec($octal)); } else { - trigger_deprecation('twig/twig', '3.12', \sprintf('Character "%s" at position %d does not need to be escaped anymore.', $nextChar, $i + 1)); + trigger_deprecation('twig/twig', '3.12', 'Character "%s" at position %d should not be escaped; the "\" character is ignored in Twig v3 but will not be in v4. Please remove the extra "\" character.', $nextChar, $i + 1); $result .= $nextChar; } diff --git a/tests/LexerTest.php b/tests/LexerTest.php index 158836ac447..f07a0868412 100644 --- a/tests/LexerTest.php +++ b/tests/LexerTest.php @@ -252,17 +252,17 @@ public function getStringWithEscapedDelimiterProducingDeprecation() yield '{{ \'App\Test\' }} => AppTest' => [ '{{ \'App\\Test\' }}', 'AppTest', - 'Since twig/twig 3.12: Character "T" at position 5 does not need to be escaped anymore.', + 'Since twig/twig 3.12: Character "T" at position 5 should not be escaped; the "\" character is ignored in Twig v3 but will not be in v4. Please remove the extra "\" character.', ]; yield '{{ "foo \\\' bar" }} => foo \' bar' => [ '{{ "foo \\\' bar" }}', 'foo \' bar', - "Since twig/twig 3.12: Character \"'\" at position 6 does not need to be escaped anymore.", + 'Since twig/twig 3.12: Character "\'" at position 6 should not be escaped; the "\" character is ignored in Twig v3 but will not be in v4. Please remove the extra "\" character.', ]; yield '{{ \'foo \" bar\' }} => foo " bar' => [ '{{ \'foo \\" bar\' }}', 'foo " bar', - 'Since twig/twig 3.12: Character """ at position 6 does not need to be escaped anymore.', + 'Since twig/twig 3.12: Character """ at position 6 should not be escaped; the "\" character is ignored in Twig v3 but will not be in v4. Please remove the extra "\" character.', ]; }