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
@return static in inheritance through extending AND implementing is not working correctly #3580
Comments
For some reason the PHPDoc isn't inherited but should be, this works: https://phpstan.org/r/ba0bfb07-1237-47cd-a61f-5d3bb34a6ff5 |
Yes! This is my workaround. Thank you :-) |
@josefsabl After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
+PHP 7.4 – 8.0 (1 error)
+==========
+
+26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+14: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone().
26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo. Full reportPHP 7.4 – 8.0 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-No errors
+PHP 7.4 – 8.0
+==========
+
+No errors
+
+PHP 7.1 – 7.3 (1 error)
+==========
+
+17: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone(). Full reportPHP 7.4 – 8.0No errors PHP 7.1 – 7.3 (1 error)
|
@josefsabl After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
+PHP 7.4 – 8.1 (1 error)
+==========
+
+26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+14: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone().
26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo. Full reportPHP 7.4 – 8.1 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-No errors
+PHP 7.4 – 8.1
+==========
+
+No errors
+
+PHP 7.1 – 7.3 (1 error)
+==========
+
+17: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone(). Full reportPHP 7.4 – 8.1No errors PHP 7.1 – 7.3 (1 error)
|
@josefsabl After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 7.4 – 8.2 (1 error)
+==========
+
+26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+14: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone().
26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo. Full reportPHP 7.4 – 8.2 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@ondrejmirtes After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-No errors
+PHP 7.4 – 8.2
+==========
+
+No errors
+
+PHP 7.1 – 7.3 (1 error)
+==========
+
+17: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone(). Full reportPHP 7.4 – 8.2No errors PHP 7.1 – 7.3 (1 error)
|
@josefsabl After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 7.4 – 8.3 (1 error)
+==========
+
+26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+14: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone().
26: Method TheFooMaker::make() should return TheFoo but returns BaseFoo. Full reportPHP 7.4 – 8.3 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@ondrejmirtes After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-No errors
+PHP 7.4 – 8.3
+==========
+
+No errors
+
+PHP 7.1 – 7.3 (1 error)
+==========
+
+17: Return type BaseFoo of method BaseFoo::getClone() is not compatible with return type TheBaseFoo of method TheBaseFoo::getClone(). Full reportPHP 7.4 – 8.3No errors PHP 7.1 – 7.3 (1 error)
|
Fixed: phpstan/phpstan-src#2803 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Not sure how to better explain the situation. Please see the code snippet.
Code snippet that reproduces the problem
https://phpstan.org/r/7ee5959d-2f86-40af-b006-e9b30d129ca0
Expected output
No error.
The text was updated successfully, but these errors were encountered: