diff --git a/kernel/private/classes/ezautoloadgenerator.php b/kernel/private/classes/ezautoloadgenerator.php index 0efd3692283..96f4a1b38d4 100644 --- a/kernel/private/classes/ezautoloadgenerator.php +++ b/kernel/private/classes/ezautoloadgenerator.php @@ -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' );