Skip to content

Commit

Permalink
SyntaxError::getNormalizedMessage(): minor regex tweak
Browse files Browse the repository at this point in the history
By using `?:` at the start of a parenthesis group, the group will not be "remembered"/saved to memory.

As this regex does not use the subgroups anyway, we don't need to remember them.
  • Loading branch information
jrfnl authored and grogy committed Apr 19, 2022
1 parent c592842 commit 41a9c77
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Errors/SyntaxError.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getLine()
*/
public function getNormalizedMessage($translateTokens = false)
{
$message = preg_replace('~^(Parse|Fatal) error: (syntax error, )?~', '', $this->message);
$message = preg_replace('~^(?:Parse|Fatal) error: (?:syntax error, )?~', '', $this->message);
$baseName = basename($this->filePath);
$regex = sprintf(self::IN_ON_REGEX, preg_quote($baseName, '~'));
$message = preg_replace($regex, '', $message, -1, $count);
Expand Down

0 comments on commit 41a9c77

Please sign in to comment.