You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic throw type reported as missing in @throws even when annotated #9497
------ ----------------------------------------------------------------------------------------------------------------------
Line Test.php
------ ----------------------------------------------------------------------------------------------------------------------
11 Method Test::sayHello() throws checked exception T of RuntimeException but it's missing from the PHPDoc @throws tag.
------ ----------------------------------------------------------------------------------------------------------------------
@@ @@-No errors+PHP 8.1 – 8.2+==========++No errors++PHP 7.2 – 8.0 (4 errors)+==========++ 9: Method Test::sayHello() has invalid return type never.+11: Method Test::sayHello() should return never but return statement is missing.+21: Tip: Method Test::throwIt() always throws an exception, it should have return type "never".+21: Method Test::throwIt() has invalid return type never.
Full report
PHP 8.1 – 8.2
No errors
PHP 7.2 – 8.0 (4 errors)
Line
Error
9
Method Test::sayHello() has invalid return type never.
11
Method Test::sayHello() should return never but return statement is missing.
21
Tip: Method Test::throwIt() always throws an exception, it should have return type "never".
21
Method Test::throwIt() has invalid return type never.
Activity
devnix commentedon Sep 24, 2023
Watching closely, it would be great to have this!
phpstan-bot commentedon Sep 4, 2024
@janedbal After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.1 – 8.2
No errors
PHP 7.2 – 8.0 (4 errors)
Method Test::sayHello() has invalid return type never.Method Test::sayHello() should return never but return statement is missing.Tip: Method Test::throwIt() always throws an exception, it should have return type "never".Method Test::throwIt() has invalid return type never.JeroenTriptic commentedon Nov 19, 2024
As this issue is still open, I would also like the same thing but with class string: https://phpstan.org/r/2eaf4c8a-3bf8-447f-8d99-4f5f758b22a2
ondrejmirtes commentedon Mar 25, 2026
Reproductions: https://phpstan.org/r/d0c6f678-3a56-465d-8c2c-593225dc0de4
https://phpstan.org/r/0d7dda93-9f11-4eb7-b36a-ff80be44e5c7
Add regression tests for generic @throws T resolved at call sites
Add regression tests for generic @throws T resolved at call sites
Add regression tests for generic @throws T resolved at call sites
Add regression tests for generic @throws T resolved at call sites
Add regression tests for generic @throws T resolved at call sites
phpstan-bot commentedon Sep 20, 2026
Closed via merging phpstan/phpstan-src#5874
github-actions commentedon Oct 22, 2026
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.