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

Commit c3b7e29

Browse files
committed
Fix: Ignore anonymous classes
1 parent 484e5c8 commit c3b7e29

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ClassFileLocator.php

+12
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ public function accept()
123123
if ($i > 0 && is_array($tokens[$i - 1]) && $tokens[$i - 1][0] === T_DOUBLE_COLON) {
124124
break;
125125
}
126+
127+
// ignore anonymous classes on PHP 7.1 and greater
128+
if (PHP_VERSION_ID >= 70100
129+
&& $i > 2
130+
&& \is_array($tokens[$i - 1])
131+
&& $tokens[$i - 1][0] === T_WHITESPACE
132+
&& \is_array($tokens[$i - 2])
133+
&& $tokens[$i - 2][0] === T_NEW
134+
) {
135+
break;
136+
}
137+
126138
// no break
127139
case T_INTERFACE:
128140
// Abstract class, class, interface or trait found

0 commit comments

Comments
 (0)