Skip to content

use more fine grained result-cache invalidation #1061

Closed

Description

@staabm

disclaimer: I never used phpstan-drupal, so my assumptions might be wrong


As far as I understand the code there is some result-cache invalidation implemented via

final class BootstrapResultCacheMetaExtension implements ResultCacheMetaExtension

with 2.3.x arround the corner, we added some more fine grained mechanisms which allow your extension to tell phpstan while analysis which files depend on which other files. that way a more fine grained cache invalidation happens (and only in case something really changes).

in phpstan/phpstan-symfony@d9c130e you can see how phpstan-symfony was adapted to make use of this new extension type, which will be available as of 2.3.0.

docs have been added

I want to make you aware of that new functionality so you can look into implementing it and provide feedback whether this works for you

Activity

  1. staabm commented on Oct 1, 2026

    @staabm
    Author

    note: apis have been renamed in phpstan/phpstan-src#6644

  2. travis-bradbury commented on Oct 22, 2026

    @travis-bradbury
    Contributor
  3. mglaman commented on Nov 5, 2026

    @mglaman
    Owner

    Thanks for flagging this. We'll migrate in phpstan-drupal 2.3.0 and require phpstan/phpstan: ^2.3. Drupal core's main, 11.x, and 11.5.x branches already require ^2.3.4, so there's no reason to carry both APIs.

    I'll post feedback on the API here as we work through it.

  4. mglaman commented on Nov 5, 2026

    @mglaman
    Owner

    Feedback from migrating: getValue() runs in the main process before bootstrapFiles when the cache is restored. phpstan-drupal fills its service map in a bootstrap file, so:

    • Our ResultCacheMetaExtension hashed empty state on 2.3 and never invalidated.
    • Our first value extension returned a different value in workers than on restore, so every file re-analyzed on every run.

    We fixed it by reading the site from disk without the bootstrap (#1071). Nothing failed or warned, so other extensions that populate state in a bootstrap file could hit the same thing. Could the docs and the ResultCacheValueExtension docblock mention that these methods can't rely on bootstrapFiles?

  5. added a commit that references this issue on Nov 5, 2026
    517b460
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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions