-
-
Notifications
You must be signed in to change notification settings - Fork 934
Open
phpstan/phpstan-src
#4229Labels
Milestone
Description
Bug report
I believe param-outs should follow the same logic as the return type, and not complain for unused types to allow for covariance in derived classes, unless the method or the class is final of course, or it's a function.
class C {
/**
* @param mixed $x
* @param-out string|int $x
*/
public function foo(&$x): void {
// Method C::foo() never assigns int to &$x so it can be removed from the @param-out type.
$x = "foo";
}
}
class D extends C {
public function foo(&$x): void {
// Method D::foo() never assigns string to &$x so it can be removed from the @param-out type.
$x = 42;
}
}
Code snippet that reproduces the problem
https://phpstan.org/r/17b75b5d-b375-495e-8814-75ee40785759
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
No response