Skip to content

Remove Reflector from StubFilesExtensionLoader#747

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

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

Conversation

@xificurk
Copy link
Copy Markdown
Contributor

@xificurk xificurk commented May 7, 2026

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 xificurk force-pushed the stub-loader-without-reflection branch 3 times, most recently from 56efd04 to 27635c4 Compare May 7, 2026 22:37
Comment thread src/Stubs/Doctrine/StubFilesExtensionLoader.php
@staabm
Copy link
Copy Markdown
Contributor

staabm commented May 9, 2026

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 xificurk force-pushed the stub-loader-without-reflection branch from 70c5abf to fe4eefa Compare May 9, 2026 08:07
@xificurk
Copy link
Copy Markdown
Contributor Author

xificurk commented May 9, 2026

Done, PR is fix only now.

@staabm staabm changed the title Remove Reflector from StubFilesExtensionLoader, add regression test Remove Reflector from StubFilesExtensionLoader May 9, 2026
@staabm staabm merged commit e87516b into phpstan:2.0.x May 9, 2026
51 of 52 checks passed
@staabm
Copy link
Copy Markdown
Contributor

staabm commented May 9, 2026

thank you

@xificurk xificurk deleted the stub-loader-without-reflection branch May 9, 2026 08:16
Sign up for free to 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