You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolve bootstrap autoloaders' classes from the files they ask for, running them for real only when that cannot redeclare a symbol
The function_exists($className) gate added for phpstan/phpstan#14988
confused two meanings of "functions": AutoloadFunctionsSourceLocator is
about autoload functions - the spl_autoload_register() callbacks that
bootstrap files register - not about class names coinciding with defined
functions. Executed for a class, such an autoloader either asks for a
file, which the file-read trap detects, or defines the class without one,
through class_alias() or eval().
The gate's probe also poisoned its own evidence: a trapped include
succeeds with empty content, defining nothing but still registering in
get_included_files(), so comparing the trapped files against
get_included_files() taken after the probe declined the very lookup it
was probing. Laravel's facade aliases whose target class is not loaded
yet hit exactly that: resolving Redirect makes class_alias() ask for the
file of Illuminate\Support\Facades\Redirect, the probe trapped that read,
found the file "already included" and declined, and larastan's
monicahq/monica e2e failed with seven "unknown class Redirect" errors.
Any earlier probe trapping the same file poisoned later lookups the same
way, since the pseudo-include sticks for the rest of the process.
Now every lookup probes under the trap first, the class is located
statically in the files the autoloaders asked for, and the autoloaders
run for real only when executing those files could not fatally redeclare
anything - judged by the files' statically parsed symbols, which
pseudo-includes cannot poison, instead of by get_included_files().
The bug-15102c e2e covers the shape Illuminate\Foundation\AliasLoader
creates in a real Laravel app: a prepended autoloader aliasing a name
that collides with a global helper function to a class only Composer can
autoload.
See phpstan/phpstan#15102
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JkCjnojdWZvswKCPmzt4zY
0 commit comments