Allow PHPStan to understand conditional return types with generics
InvisibleSmiley opened this issue · comments
Feature Request
Q | A |
---|---|
New Feature | no |
RFC | no |
BC Break | no |
Summary
PHPStan does not understand some conditional return types which involve generics. As a result, the inferred return type is "object" rather than the class of the input parameter class-string.
Corresponding PHPStan issue: phpstan/phpstan#8049
Solution template: use class-string<T>
instead of just class-string in @psalm-return.
Occurrences in code:
- ServiceLocatorInterface::build
- AbstractPluginManager::get
Solution template: use class-string instead of just class-string in @psalm-return.
Could you rephrase, please?
Solution template: use class-string instead of just class-string in @psalm-return.
Could you rephrase, please?
Looks like you cannot simply put something in angle brackets here ;) Edited summary accordingly.
Aha... could you suggest a patch perhaps? Me and @gsteel are usually quick at picking these up, if valid :)
Opened a PR against 3.12.x where this was first introduced.
Not sure how to link the PR to this issue though.
If it's an improvement, we'll target a later branch: not a problem to retarget though, we can do it, after review :)