From bdf51ab16dd5b05e30eb578ab15daf86284b24ff Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Mon, 9 Mar 2015 10:05:12 -0700 Subject: [PATCH] Single variable for traits and enums --- src/Composer/Autoload/ClassMapGenerator.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 5134be80f..862e44ba2 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -112,10 +112,9 @@ class ClassMapGenerator */ private static function findClasses($path) { - $traits = version_compare(PHP_VERSION, '5.4', '<') ? '' : '|trait'; - $enums = ''; + $extraTypes = version_compare(PHP_VERSION, '5.4', '<') ? '' : '|trait'; if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) { - $enums = '|enum'; + $extraTypes .= '|enum'; } try { @@ -133,7 +132,7 @@ class ClassMapGenerator } // return early if there is no chance of matching anything in this file - if (!preg_match('{\b(?:class|interface'.$traits.$enums.')\s}i', $contents)) { + if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) { return array(); } @@ -158,7 +157,7 @@ class ClassMapGenerator preg_match_all('{ (?: - \b(?])(?Pclass|interface'.$traits.$enums.') \s+ (?P[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*) + \b(?])(?Pclass|interface'.$extraTypes.') \s+ (?P[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*) | \b(?])(?Pnamespace) (?P\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);