Skip to content

ClassResultCacheValueExtension can run stub files extensions before bootstrapFiles #15375

Open
phpstan/phpstan-src
#7101

Description

@canvural

Bug report

When the result cache is restored, ClassResultCacheValueExtension::getValue() calls ClassReflection::getAncestors(). In some cases that initialises StubPhpDocProvider, which runs the registered StubFilesExtensions before bootstrapFiles have run.

A comment in ResultCacheManager::restore() says restoring must not run them, because they can rely on bootstrapFiles having been executed.

Is this OK, or should stub files extensions not rely on bootstrap files any more?

I noticed it because Larastan's stub files extension reads a constant that its bootstrap file defines.

Code snippet that reproduces the problem

No response

Expected output

Stub files extensions are not run before bootstrapFiles when the result cache is restored. Or, if running them there is intended, the comment says so.

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

No response

Activity

  1. mergeable commented on Oct 4, 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 Oct 24, 2026

    @ondrejmirtes
    Member

    I feel like ClassResultCacheValueExtension shouldn't call ClassReflection::getAncestors(), it should have a more lightweight way to find out the parents that doesn't call StubPhpDocProvider at all.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions