Skip to content

Return type for methods of descendant classes? #4321

Answered by ondrejmirtes
spud asked this question in Support
Discussion options

You must be logged in to vote

Hi, this isn't so much related to PHPStan as to PHP itself. Your code doesn't work on PHP 7.3 and lower: https://3v4l.org/IVs47

It's because on PHP 7.4 and later this RFC allowed this usecase: https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ondrejmirtes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants