Skip to content

Remove Reflector from StubFilesExtensionLoader - #747

Merged
staabm merged 1 commit into
phpstan:2.0.xfrom
xificurk:stub-loader-without-reflection
May 9, 2026
Merged

Remove Reflector from StubFilesExtensionLoader#747
staabm merged 1 commit into
phpstan:2.0.xfrom
xificurk:stub-loader-without-reflection

Conversation

@xificurk

Copy link
Copy Markdown
Contributor

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 and was removed in 3.0.0, 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.

--

Related:

phpstan/phpstan-src#5577
phpstan/phpstan-src#5538 (comment)

@xificurk
xificurkforce-pushed the stub-loader-without-reflection branch 3 times, most recently from 56efd04 to 27635c4CompareMay 7, 2026 22:37
Comment threadsrc/Stubs/Doctrine/StubFilesExtensionLoader.php
@staabm

Copy link
Copy Markdown
Contributor

please remove the test again. we will cover it in phpstan/phpstan-src#5617

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.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xificurk
xificurkforce-pushed the stub-loader-without-reflection branch from 70c5abf to fe4eefaCompareMay 9, 2026 08:07
@xificurk

Copy link
Copy Markdown
ContributorAuthor

Done, PR is fix only now.

@staabmstaabm changed the title Remove Reflector from StubFilesExtensionLoader, add regression testRemove Reflector from StubFilesExtensionLoaderMay 9, 2026
@staabm
staabm merged commit e87516b into phpstan:2.0.xMay 9, 2026
51 of 52 checks passed
@staabm

Copy link
Copy Markdown
Contributor

thank you

@xificurk
xificurk deleted the stub-loader-without-reflection branch May 9, 2026 08:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@xificurk@staabm@VincentLanglet