Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Fix: Ignore anonymous classes
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 11, 2017
1 parent 6545ac6 commit eaea370
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ClassFileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public function accept()
if ($i > 0 && is_array($tokens[$i - 1]) && $tokens[$i - 1][0] === T_DOUBLE_COLON) {
break;
}

// ignore anonymous classes on PHP 7.1 and greater
if (PHP_VERSION_ID >= 70100
&& $i > 2
&& \is_array($tokens[$i - 1])
&& $tokens[$i - 1][0] === T_WHITESPACE
&& \is_array($tokens[$i - 2])
&& $tokens[$i - 2][0] === T_NEW
) {
break;
}

// no break
case T_INTERFACE:
// Abstract class, class, interface or trait found
Expand Down

0 comments on commit eaea370

Please sign in to comment.