-
Notifications
You must be signed in to change notification settings - Fork 659
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
[4.25.0] InvalidArgument for result of a method with a static return type #8330
Comments
I found these snippets: https://psalm.dev/r/6081a71dec<?php
declare(strict_types=1);
namespace HappyInc;
abstract class A
{
}
final class B extends A
{
public static function create(): static
{
return new self();
}
}
final class Service
{
public function do(): void
{
$this->acceptA(B::create());
}
private function acceptA(A $_a): void
{
}
}
|
Oh, I see, psalm.dev is at |
Hey @someniatko , it could be a result of #8249. Would you mind taking a look? |
I have the same issue with the following code https://psalm.dev/r/3765f8a43d If you need a reproducer, you can try
If it require a rework of static, might be worth taking a look at #5938 too. |
I found these snippets: https://psalm.dev/r/3765f8a43d<?php
abstract class Guess
{
/**
* @param static[] $guesses An array of guesses
*
* @return static|null
*/
public static function getBestGuess(array $guesses)
{
return $guesses[0] ?? null;
}
}
class TypeGuess extends Guess
{
}
class FooFoo
{
public function guess(TypeGuess $object): ?TypeGuess
{
return TypeGuess::getBestGuess([$object]);
}
}
|
@orklah I will take a look tomorrow. My suspect is |
@vudaltsov does it still happen if you return |
@AndrolGenhald, no, it gives the same error. Anyway, in a final class it's valid to |
…pped in ExistingAtomicStaticCallAnalyzer#hasStaticInType()
#8330 - take into account that `static` type may have been unwrapped in `hasStaticInType()`
gives
in 4.25.0.
By the way, for some reason https://psalm.dev/r/6081a71dec says "No issues!".
The text was updated successfully, but these errors were encountered: