Skip to content

Commit

Permalink
Make autoloads ignore anonymous classes (#174)
Browse files Browse the repository at this point in the history
* Make autoloads ignore anonymous classes

* Make autoloads ignore anonymous classes
  • Loading branch information
pkamps authored Jan 3, 2020
1 parent 6f9b27f commit 11362cc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/private/classes/ezautoloadgenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@ protected function getClassFileList( $fileList, $mode )
if ($tokens[$key-1][1] === '::') {
break;
}
/**
* Ignore token if class is anonymous: "new Class() {}"
* @see https://www.php.net/manual/en/language.oop5.anonymous.php
* NEW_TOKEN - WHITESPACE_TOKEN - CLASS_TOKEN
*/
if(isset($tokens[$key-2][0]) && $tokens[$key-2][0] === T_NEW) {
break;
}

// Increment stat for found class.
$this->incrementProgressStat( self::OUTPUT_PROGRESS_PHASE2, 'classCount' );
Expand Down

0 comments on commit 11362cc

Please sign in to comment.