Bug report
Accordint to PHPStan doc https://phpstan.org/writing-php-code/phpdocs-basics Using @return static along with the self native typehint means that the method returns a child class
As of 1.10.48 (not present on 1.10.47) return types at level 3 report an error like:
Method Foo::create() should return static(Foo) but returns Foo. using this example:
interface IFoo
{
/** @return static */
public static function create();
}
class Foo implements IFoo
{
public static function create(): self
{
return new self();
}
}
I don't think this is an error.
If it is an error in the code, how it could be solved?
If it is not an error, then it is a bug?
Thanks for PHPStan, it is geat!
Code snippet that reproduces the problem
https://phpstan.org/r/2eb3158b-0c10-4138-8e91-0daf17390e77
Expected output
The issue is reported incorrectly.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is a great tool, you are helping us (PhpCfdi) to maintain libre high-quality tools for Mexican PHP developers. Thanks a lot!
Reactions are currently unavailable
Bug report
Accordint to PHPStan doc https://phpstan.org/writing-php-code/phpdocs-basics Using @return static along with the self native typehint means that the method returns a child class
As of 1.10.48 (not present on 1.10.47) return types at level 3 report an error like:
Method Foo::create() should return static(Foo) but returns Foo. using this example:
I don't think this is an error.
If it is an error in the code, how it could be solved?
If it is not an error, then it is a bug?
Thanks for PHPStan, it is geat!
Code snippet that reproduces the problem
https://phpstan.org/r/2eb3158b-0c10-4138-8e91-0daf17390e77
Expected output
The issue is reported incorrectly.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is a great tool, you are helping us (PhpCfdi) to maintain libre high-quality tools for Mexican PHP developers. Thanks a lot!