Skip to content

Commit

Permalink
[Performance][Printer] Reduce regex check use( no space on BetterStan…
Browse files Browse the repository at this point in the history
…dardPrinter (#4971)

* [Printer] Reduce regex check use( no space on BetterStandardPrinter

* same behav

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Sep 10, 2023
1 parent b5c8f9a commit cda9577
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/PhpParser/Printer/BetterStandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
*/
final class BetterStandardPrinter extends Standard
{
/**
* @var string
* @see https://regex101.com/r/F5x783/1
*/
private const USE_REGEX = '#( use)\(#';

/**
* @var string
* @see https://regex101.com/r/DrsMY4/1
Expand Down Expand Up @@ -299,7 +293,7 @@ protected function pExpr_Closure(Closure $closure): string
return $closureContent;
}

return Strings::replace($closureContent, self::USE_REGEX, '$1 (');
return str_replace(' use(', ' use (', (string) $closureContent);
}

/**
Expand Down

0 comments on commit cda9577

Please sign in to comment.