Closed vudaltsov closed 2 years ago
I found these snippets:
Oh, I see, psalm.dev is at 7c4228f
, not d7cd84c
.
Hey @someniatko , it could be a result of https://github.com/vimeo/psalm/pull/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 https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/FieldDescription/TypeGuesserChain.php#L57 Which has two more issue since 4.25
ERROR: MoreSpecificReturnType - src/FieldDescription/TypeGuesserChain.php:57:73 - The declared return type 'Symfony\Component\Form\Guess\TypeGuess|null' for Sonata\AdminBundle\FieldDescription\TypeGuesserChain::guess is more specific than the inferred return type 'Symfony\Component\Form\Guess\Guess&static|null' (see https://psalm.dev/070)
public function guess(FieldDescriptionInterface $fieldDescription): ?TypeGuess
ERROR: LessSpecificReturnStatement - src/FieldDescription/TypeGuesserChain.php:69:16 - The type 'Symfony\Component\Form\Guess\Guess&static|null' is more general than the declared return type 'Symfony\Component\Form\Guess\TypeGuess|null' for Sonata\AdminBundle\FieldDescription\TypeGuesserChain::guess (see https://psalm.dev/129)
return TypeGuess::getBestGuess($guesses);
If it require a rework of static, might be worth taking a look at https://github.com/vimeo/psalm/issues/5938 too.
I found these snippets:
@orklah I will take a look tomorrow. My suspect is hasStaticInType()
returned false for some reason, but that's really strange, there should be enough tests already written, one of which should have caught this.
@vudaltsov does it still happen if you return new static()
instead of new self()
? Maybe that's the culprit?
@AndrolGenhald, no, it gives the same error. Anyway, in a final class it's valid to return new self
in a : static
method.
gives
in 4.25.0.
By the way, for some reason https://psalm.dev/r/6081a71dec says "No issues!".