Closed GrahamCampbell closed 4 years ago
NB This syntax for callable typing is standard, and is agreed between both PHPStan and Psalm (and others), and understood by PHPStorm. In the absence of any universality accepted specification of phpdoc syntax, I think this is the best I can say.
Static analysers (such as Psalm) complain if someone adds this typing information to their own class which extends this interface because what they have affectively done is specialised the types, which is not allowed. It's the same as an interface saying
string|int
but the implementation only acceptingstring
. So, with this in mind, we should take the opportunity to provide the most specific type information we can.For reference, an error produced by Psalm (without this PR):
and by PHPStan: