Skip to content

Commit

Permalink
Make autoloads ignore anonymous classes (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
IotaBlack authored and andrerom committed Dec 18, 2019
1 parent 1b70a7a commit 625d836
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($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 625d836

Please sign in to comment.