-
Notifications
You must be signed in to change notification settings - Fork 667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UndefinedDocblockClass for generic template #2697
Comments
@simPod I removed the ability to use templated classes in static methods because it's easy to get things wrong – I created a feature request in PHPStan's repo here: phpstan/phpstan#2738, and here's a link to where I announced I was mentioned that I was breaking this feature in Psalm: phpstan/phpstan#2731 (comment) |
Thanks for links! Can you briefly explain what does |
No, it's about thinking that you have some sort of templated protections & inference on input, when in fact you don't. The author was intending for |
I see the issue but isn't there the same problem with calling it through dynamic context? https://phpstan.org/r/da30f478-a9fe-4e67-972d-351e1965b531 |
@muglug if you had a few seconds I'd be very curious on your view here. It doesn't "click" together to me now :( Thanks! |
I think your example should now work in Psalm - after further consideration I reverted to the more-permissive behaviour. |
I found these snippets: https://psalm.dev/r/56eabbc3e2<?php
class Output {
}
/** @template O of Output */
interface Format
{
/** @psalm-return O */
public static function output(string $contents) : Output;
}
|
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
Psalm does not support class @template in static methods. And in PHPStan it does not protect. See - vimeo/psalm#2697 - phpstan/phpstan#2738
I'm getting
This works just fine with phpstan. I went through docs and some internal stubs here and can't see what I'm doing wrong. Why psalm does not know
O
for@return
when it's defined as a template? Thanks!The text was updated successfully, but these errors were encountered: