Uh oh!
There was an error while loading. Please reload this page.
Add a dynamic stub loader to prefer upstream types - #481
Conversation
The remaining stubs belong to a few categories:
|
Once the precise types are added in Symfony, the upstream types should be used to benefit from the maintenance work of the Symfony team.
| private function isInstalledVersionBelow(string $package, string $maxVersion): bool | ||
| { | ||
| if (!class_exists(InstalledVersions::class)) { | ||
| return false; |
There was a problem hiding this comment.
In which case this will occur ?
Should we return true, just to avoid a BC break ?
There was a problem hiding this comment.
I think this could happen when using a phpstan phar without loading the project composer autoloader (which likely causes issues). Otherwise, it should not happen when using composer 2+.
I copied this condition from the stub loader of phpstan-doctrine.
| if ($this->isInstalledVersionBelow('symfony/http-foundation', '7.4.0.0')) { | ||
| $files[] = $stubsDir . '/Symfony/Component/HttpFoundation/ParameterBag.stub'; | ||
| try { |
There was a problem hiding this comment.
Can't we check that the version is >= some version ?
There was a problem hiding this comment.
I could. I copied the way it was done in the existing code that I moved here (to avoid having to handle coordinated conditions between 2 loaders).
Tell me whether you want me to do the change).
For reference, InputBag shipped in version 5.1.0 of the component.
There was a problem hiding this comment.
Didn't see it was coming from another file
Most remaining stub types (i.e. all except form types and the |
| - stubs/Psr/Cache/CacheException.stub | ||
| - stubs/Psr/Cache/CacheItemInterface.stub | ||
| - stubs/Psr/Cache/InvalidArgumentException.stub | ||
| - stubs/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.stub |
There was a problem hiding this comment.
what is the case for files which still are referenced in extension.neon?
are these required for every symfony version?
stof
commented
Apr 22, 2026
@VincentLanglet As the Symfony PR is merged, do you prefer that I update this PR with the conditional loading for Symfony 8.1.0 or keeping it as a follow-up PR (as this PR is already approved) ? |
VincentLanglet
commented
Apr 22, 2026
I'm fine with both. I wait for the approval from staabm anyway |
stof
commented
Apr 22, 2026
@VincentLanglet@staabm I pushed my commit handling the stubs covered in Symfony 8.1 then (I already had it ready locally). |
31f4fba to
02a7a81Compare
Once the precise types are added in Symfony, the upstream types should be used to benefit from the maintenance work of the Symfony team.
Closes#431