From 5db04d79dd900ddc699b9ca029c5ece6ffceceaa Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 17 Apr 2025 14:02:45 +0700 Subject: [PATCH] [Php73] Fix escaped single quote on RegexDashEscapeRector --- .../Fixture/escaped_quote.php.inc | 23 +++++++++++++++++++ .../Rector/FuncCall/RegexDashEscapeRector.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 rules-tests/Php73/Rector/FuncCall/RegexDashEscapeRector/Fixture/escaped_quote.php.inc diff --git a/rules-tests/Php73/Rector/FuncCall/RegexDashEscapeRector/Fixture/escaped_quote.php.inc b/rules-tests/Php73/Rector/FuncCall/RegexDashEscapeRector/Fixture/escaped_quote.php.inc new file mode 100644 index 00000000000..e4e3e168c42 --- /dev/null +++ b/rules-tests/Php73/Rector/FuncCall/RegexDashEscapeRector/Fixture/escaped_quote.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php b/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php index be007c1bc10..7785b6aa47f 100644 --- a/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php +++ b/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php @@ -82,7 +82,7 @@ public function refactor(Node $node): ?Node return null; } - $stringValue = $node->value; + $stringValue = trim($node->getAttribute(AttributeKey::RAW_VALUE) ?? $node->value, '"\''); if (StringUtils::isMatch($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX)) { $node->value = Strings::replace($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX, '$1\-');