Skip to content

Commit

Permalink
Merge pull request #820 from simPod/cleanup-extra-types
Browse files Browse the repository at this point in the history
Drop extratypes from CacheWarmer
  • Loading branch information
goetas committed Jan 13, 2021
2 parents 6a0aa33 + 4c9f0eb commit fb6f454
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Cache/CacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ public function isOptional()
*/
private static function findClasses($path)
{
$extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
$extraTypes .= '|enum';
}

// Use @ here instead of Silencer to actively suppress 'unhelpful' output
// @link https://github.com/composer/composer/pull/4886
$contents = @php_strip_whitespace($path);
Expand All @@ -92,7 +87,7 @@ private static function findClasses($path)
}

// return early if there is no chance of matching anything in this file
if (!preg_match('{\b(?:class|interface' . $extraTypes . ')\s}i', $contents)) {
if (!preg_match('{\b(?:class|interface|trait)\s}i', $contents)) {
return array();
}

Expand All @@ -117,7 +112,7 @@ private static function findClasses($path)

preg_match_all('{
(?:
\b(?<![\$:>])(?P<type>class|interface' . $extraTypes . ') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
\b(?<![\$:>])(?P<type>class|interface|trait) \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
| \b(?<![\$:>])(?P<ns>namespace) (?P<nsname>\s++[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\s*+\\\\\s*+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+)? \s*+ [\{;]
)
}ix', $contents, $matches);
Expand Down

0 comments on commit fb6f454

Please sign in to comment.