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

Commit c359f7f

Browse files
committed
Fix: Ignore anonymous classes
1 parent a2cec18 commit c359f7f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/ClassFileLocator.php

+11
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ public function accept()
122122
if ($i > 0 && is_array($tokens[$i - 1]) && $tokens[$i - 1][0] === T_DOUBLE_COLON) {
123123
break;
124124
}
125+
126+
// ignore anonymous classes on PHP 7.1 and greater
127+
if (&& $i >= 2
128+
&& \is_array($tokens[$i - 1])
129+
&& T_WHITESPACE === $tokens[$i - 1][0]
130+
&& \is_array($tokens[$i - 2])
131+
&& T_NEW === $tokens[$i - 2][0]
132+
) {
133+
break;
134+
}
135+
125136
// no break
126137
case T_INTERFACE:
127138
// Abstract class, class, interface or trait found

0 commit comments

Comments
 (0)