From 6ab1b6a7d2d4a9cd708030b85181d70883d50b24 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 23 Aug 2021 22:18:03 +0200 Subject: [PATCH] Regex simplifications --- src/Composer/Autoload/ClassMapGenerator.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index b37fb25ca272..2c46d000ef84 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -253,20 +253,13 @@ private static function findClasses($path) (?:\r\n|\n|\r) # the meat of it, matching line by line until end delimiter (?: - # a valid line is either.. - (?: - # non-word or non-space char, then anything goes for the rest of the line - [^\s\w][^\r\n]+ - # white-space (possessive match) not followed by the end delimiter, then anything goes for the rest of the line - | \s*+(?!\\2 \s*[;,.)])[^\r\n]+ - # white-space but no new lines - | [\t\f\v ]+ - ) + # a valid line is optional white-space (possessive match) not followed by the end delimiter, then anything goes for the rest of the line + [\t ]*+(?!\\2 [\t \r\n]*[;,.)])[^\r\n]* # end of line(s) [\r\n]+ )* # end delimiter - \s* \\2 (?=\s*[;,.)]) + [\t ]* \\2 (?=[\t \r\n]*[;,.)]) }x', 'null', $contents); // strip strings