Remove Reflector from StubFilesExtensionLoader, add regression test#747
Remove Reflector from StubFilesExtensionLoader, add regression test#747xificurk wants to merge 3 commits intophpstan:2.0.xfrom
Conversation
f7f32f1 to
56efd04
Compare
Replace the expensive `reflectClass('...ServiceEntityRepository')` call with a
cheap `InstalledVersions::getVersion('doctrine/doctrine-bundle')` + `version_compare`
check. LazyServiceEntityRepository became ServiceEntityRepository's parent in
DoctrineBundle 2.8.1, so the version threshold is exact.
Add StubFilesExtensionLoaderTest with ThrowingSourceLocator registered as
`betterReflectionSourceLocator` in the test container — any future attempt to
re-introduce reflectClass() in getFiles() will immediately throw.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56efd04 to
27635c4
Compare
| return false; | ||
| } | ||
|
|
||
| return version_compare($bundleVersion, '2.8.1', '>=') && version_compare($bundleVersion, '3.0.0', '<'); |
There was a problem hiding this comment.
Given the fact we're only testing doctrine/orm 16+
phpstan-doctrine/composer.json
Line 30 in 8af50e2
I was wondering about updating the conflict section
phpstan-doctrine/composer.json
Line 17 in 8af50e2
WDYT @staabm ?
This way this method would only become isInstalledVersion(doctrine/bundle, 2)
There was a problem hiding this comment.
doctrine/orm 16+
you mean 2.16+ I guess?
I was wondering about updating the conflict section
how would you change it? it seems the "doctrine/orm": "<2.5", constraints exists for over 10 years in this extensiions
There was a problem hiding this comment.
Beware that this is a version check against doctrine/doctrine-bundle, not the core doctrine lib.
Test that BetterReflection is not initialized when ResultCacheManager constructs the ResultCache, which is the real-world code path that exercises StubFilesExtensionLoader::getFiles(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
It uses transitively uses reflection provider from ReflectionProviderStaticAccessor which is properly initialized by ContainerFactory::postInitializeContainer
Replace the expensive
reflectClass('...ServiceEntityRepository')call with a cheapInstalledVersions::getVersion('doctrine/doctrine-bundle')+version_comparecheck. LazyServiceEntityRepository became ServiceEntityRepository's parent in DoctrineBundle 2.8.1 and was removed in 3.0.0, so the version threshold is exact.Add StubFilesExtensionLoaderTest with ThrowingSourceLocator registered as
betterReflectionSourceLocatorin the test container — any future attempt to re-introduce reflectClass() in getFiles() will immediately throw.--
Related:
phpstan/phpstan-src#5577
phpstan/phpstan-src#5538 (comment)