Skip to content

Commit f04e5dd

Browse files
phpstan-botclaude
andcommitted
Document how the bug-12972b e2e autoloader reproduces the issue
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 3c7833b commit f04e5dd

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

e2e/bug-12972b/autoloader.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
require_once __DIR__ . '/vendor/autoload.php';
44

5+
// Registered *after* Composer's class loader: the third argument (prepend)
6+
// defaults to false, so this ends up at the back of the spl_autoload queue.
7+
//
8+
// \other12972\MyClass is part of Composer's class map (see composer.json), so at
9+
// runtime Composer's class loader resolves it first and this autoloader is never
10+
// invoked for it - running `php real-world.php` therefore never throws.
11+
//
12+
// PHPStan must mirror that order: the Composer class map source locator has to
13+
// resolve the class before this bootstrap autoloader is consulted. Analysing the
14+
// project used to invoke this autoloader first, hitting the LogicException and
15+
// crashing with an internal error that cannot happen at runtime.
516
spl_autoload_register(function($class) {
617
if ($class === \other12972\MyClass::class) {
718
throw new LogicException('this should not happen');

0 commit comments

Comments
 (0)