Skip to content

PHPStan autoloader mechanics invoked for case which does not use autoloading at runtime #14976

Open
phpstan/phpstan-src
#6069

Description

@staabm

Bug report

the PR at phpstan/phpstan-src#4003 adds a end-to-end test which fails atm.

runtime: run php real-world.php
you see the program runs, without the custom autoloader of e2e/bug-12972b/autoloader.php beeing invoked.
all involved classes are autoloaded by the composer class loader. the custom class loader is not invoked for \other12972\MyClass::class.


static analysis time: run ../../bin/phpstan analyze

you see PHPStan invokes the custom class loader for class \other12972\MyClass::class, which does not happen at regular runtime. the composer class loader is not invoked for \other12972\MyClass::class (like it is at runtime).

because of the difference in autoloading functions order in runtime vs. analysis time we see errors which cannot happen at runtime

Code snippet that reproduces the problem

No response

Expected output

phpstan should not analyze the code as if the autoloader was invoked (as we saw it isn't at runtime)

Did PHPStan help you today? Did it make you happy in any way?

No response

Activity

  1. mergeable commented on Jul 20, 2026

    @mergeable

    This bug report is missing a link to reproduction at phpstan.org/try.

    It will most likely be closed after manual review.

  2. ondrejmirtes commented on Aug 27, 2026

    @ondrejmirtes
    Member

    Opening this again because the solution broke too many common use cases and the patches didn't make the situation better.

    Fix reverted in phpstan/phpstan-src#6292.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions