Use external file dependencies instead of ResultCacheMetaExtension#478
Draft
janedbal wants to merge 1 commit intophpstan:2.0.xfrom
Draft
Use external file dependencies instead of ResultCacheMetaExtension#478janedbal wants to merge 1 commit intophpstan:2.0.xfrom
janedbal wants to merge 1 commit intophpstan:2.0.xfrom
Conversation
Replace SymfonyContainerResultCacheMetaExtension (which caused full cache invalidation on any container change) with PHPStan's new external file dependency tracking. Now when the container XML changes, only files that actually call Container::get(), Container::has(), getParameter(), or hasParameter() are re-analyzed instead of the entire project. All extensions and rules that read from ServiceMap or ParameterMap now register the container XML path as an external file dependency via ExternalFileDependencyRegistrar. The new parameters are optional (nullable) for backward compatibility with older PHPStan versions. Co-Authored-By: Claude Code
Draft
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SymfonyContainerResultCacheMetaExtension(which caused full cache invalidation on any container change) with PHPStan's new external file dependency trackingContainer::get(),Container::has(),getParameter(), orhasParameter()are re-analyzed instead of the entire projectMotivation
The current
SymfonyContainerResultCacheMetaExtensionhashes the entire DI container state. Any change to any service definition invalidates the entire PHPStan result cache. On large Symfony projects with frequent service changes, this causes constant full re-analyses.With this change, only the files that actually use the container (typically a few dozen controller/service files) are re-analyzed when the container XML changes — not the entire codebase.
See: #455
Depends on: phpstan/phpstan-src#5364
Changes
ServiceDynamicReturnTypeExtension: registers container XML as external dependency whenContainer::get()/has()is calledParameterDynamicReturnTypeExtension: same forgetParameter()/hasParameter()ContainerInterfacePrivateServiceRule/ContainerInterfaceUnknownServiceRule: same for rule checksextension.neon: passescontainerXmlPathto extensions, removesSymfonyContainerResultCacheMetaExtensionrules.neon: moves container rules to services with explicitcontainerXmlPathargumentAll new parameters are nullable with defaults for backward compatibility with older PHPStan versions.
Test plan
Co-Authored-By: Claude Code