-
Notifications
You must be signed in to change notification settings - Fork 672
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
[Enhancement] Emit an error when phpdoc is impossible #5990
Comments
I found these snippets: https://psalm.dev/r/af5065a4c0<?php
/**
* @method array bar()
*/
interface Foo
{
public function bar(): string;
}
function test(Foo $foo): string
{
return $foo->bar();
}
|
I think it should be consistent with |
I found these snippets: https://psalm.dev/r/cba0b4b5a3<?php
/**
* @method array bar()
*/
interface Foo
{
public function bar(): string;
/** @return array */
public function baz(): string;
}
function test(Foo $foo): string
{
if (rand(0, 1)) {
return $foo->bar();
} else {
return $foo->baz();
}
}
|
I think this is a duplicate of #5786 |
We don't have any inheritance here, so the only possible developer intent is to clarify native return type. This makes it very clear that contradiction is a different problem to LSP violations that linked ticket discusses. |
https://psalm.dev/r/af5065a4c0 emits a MismatchingDocblockReturnType now, so it should be okay now |
I found these snippets: https://psalm.dev/r/af5065a4c0<?php
/**
* @method array bar()
*/
interface Foo
{
public function bar(): string;
}
function test(Foo $foo): string
{
return $foo->bar();
}
|
https://psalm.dev/r/af5065a4c0
Given that
bar
has a native return type ofstring
, shouldn't psalm be able to emit an error that the phpdoc is invalid? I'm thinking that phpdoc should only become the source of truth if there are no native typehints or the typehints are castable to each other..The text was updated successfully, but these errors were encountered: