File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ class FileLocator implements FileLocatorInterface
2828 */
2929 protected $ autoloader ;
3030
31+ /**
32+ * List of classnames that did not exist.
33+ *
34+ * @var list<class-string>
35+ */
36+ private array $ invalidClassnames = [];
37+
3138 public function __construct (Autoloader $ autoloader )
3239 {
3340 $ this ->autoloader = $ autoloader ;
@@ -288,14 +295,20 @@ public function findQualifiedNameFromPath(string $path)
288295 ),
289296 '\\'
290297 );
291-
292298 // Remove the file extension (.php)
293299 $ className = mb_substr ($ className , 0 , -4 );
294300
301+ if (in_array ($ className , $ this ->invalidClassnames , true )) {
302+ continue ;
303+ }
304+
295305 // Check if this exists
296306 if (class_exists ($ className )) {
297307 return $ className ;
298308 }
309+
310+ // If the class does not exist, it is an invalid classname.
311+ $ this ->invalidClassnames [] = $ className ;
299312 }
300313 }
301314
You can’t perform that action at this time.
0 commit comments