File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ public function create(
8282 public function createAnonymousFunctionFromExpr (Expr $ expr ): ?Closure
8383 {
8484 $ stringValue = $ this ->inlineCodeParser ->stringify ($ expr );
85- $ stringValue = $ this ->normalizeHexBackreferenceExpression ($ stringValue );
8685
8786 $ phpCode = '<?php ' . $ stringValue . '; ' ;
8887 $ contentStmts = $ this ->simplePhpParser ->parseString ($ phpCode );
@@ -126,24 +125,6 @@ public function createAnonymousFunctionFromExpr(Expr $expr): ?Closure
126125 return $ anonymousFunction ;
127126 }
128127
129- private function normalizeHexBackreferenceExpression (string $ stringValue ): string
130- {
131- // Only rewrite when the expression has no quotes, to avoid mutating string literals.
132- if (str_contains ($ stringValue , "' " ) || str_contains ($ stringValue , '" ' )) {
133- return $ stringValue ;
134- }
135-
136- return Strings::replace (
137- $ stringValue ,
138- '#0x(?<backreference> \\\d+|\$\d+)# ' ,
139- static function (array $ match ): string {
140- $ backreference = $ match ['backreference ' ];
141- $ number = ltrim ($ backreference , '\\$ ' );
142- return 'hexdec($matches[ ' . $ number . ']) ' ;
143- }
144- );
145- }
146-
147128 /**
148129 * @param Param[] $params
149130 * @return string[]
Original file line number Diff line number Diff line change 5353 private const string BACKREFERENCE_NO_DOUBLE_QUOTE_START_REGEX = '#(?<!")(?<backreference>\$\d+)# ' ;
5454
5555 /**
56- * @see https://regex101.com/r/8Dk7Qn /1
56+ * @see https://regex101.com/r/13mVVg /1
5757 */
58- private const string HEX_BACKREFERENCE_REGEX = '#0x(?<backreference> \\ \d+|\ $\d+)# ' ;
58+ private const string HEX_BACKREFERENCE_REGEX = '#0x(?<backreference>\$\d+)# ' ;
5959
6060 public function __construct (
6161 private BetterStandardPrinter $ betterStandardPrinter ,
You can’t perform that action at this time.
0 commit comments