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

Commit b91ff16

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

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
@@ -122,6 +122,18 @@ 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 (PHP_VERSION_ID >= 70100
128+
&& $i >= 2
129+
&& \is_array($tokens[$i - 1])
130+
&& T_WHITESPACE === $tokens[$i - 1][0]
131+
&& \is_array($tokens[$i - 2])
132+
&& T_NEW === $tokens[$i - 2][0]
133+
) {
134+
break;
135+
}
136+
125137
// no break
126138
case T_INTERFACE:
127139
// Abstract class, class, interface or trait found

0 commit comments

Comments
 (0)