Skip to content

Remove Reflector from StubFilesExtensionLoader, add regression test#747

Open
xificurk wants to merge 1 commit intophpstan:2.0.xfrom
xificurk:stub-loader-without-reflection
Open

Remove Reflector from StubFilesExtensionLoader, add regression test#747
xificurk wants to merge 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 2 times, most recently from f7f32f1 to 56efd04 Compare May 7, 2026 22:32
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>
@xificurk xificurk force-pushed the stub-loader-without-reflection branch from 56efd04 to 27635c4 Compare May 7, 2026 22:37
return false;
}

return version_compare($bundleVersion, '2.8.1', '>=') && version_compare($bundleVersion, '3.0.0', '<');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the fact we're only testing doctrine/orm 16+

"doctrine/orm": "^2.16.0",

I was wondering about updating the conflict section

"doctrine/orm": "<2.5",

WDYT @staabm ?

This way this method would only become isInstalledVersion(doctrine/bundle, 2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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