-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Imagine the following:
interface IFoo
{
/**
* @return string[]
*/
public function foo(): array;
}
class Foo implements IFoo
{
/**
* @return string[]
*/
public function foo(): array
{
throw new \Exception('This should never happen');
}
}This gives me the following error message:
Function has no return statement, but annotation @return is present (Squiz.Commenting.FunctionComment.InvalidNoReturn)
There's two possible solutions:
- Drop the
@returntag- This makes the code invalid because
Fooisn't compatible withIFoo - This will be checked in PHPStan in the future
- This makes the code invalid because
- Add a dummy-return after the
throw \Exception- This is obviously also not great as you'll get a "unreachable statement" warning
This is probably very very hard to track without an AST...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels