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
"$variable might not be defined" errors when using exhaustive if statements with constant enums #5266
When using constant enums on function parameters, variables that are declared inside an exhaustive if statement are reported as might not be defined, even though it's certainly defined.
There should be no error reported, as every case of the constant enum is covered by the if statement, and every branch of the if statement declares the $message variable
@@ @@-No errors+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40+Run PHPStan with --debug option and post the stack trace to:+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Full report
Line
Error
-1
Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40Run PHPStan with --debug option and post the stack trace to:https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Activity
ondrejmirtes commentedon Jul 8, 2021
Yeah, this could be fixed. Until then you can use the following equivalent code: https://phpstan.org/r/d7bdc041-191c-499e-bc00-2309a598f6d4
phpstan-bot commentedon Sep 23, 2021
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
Full report
Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40Run PHPStan with --debug option and post the stack trace to:https://github.com/phpstan/phpstan/issues/new?template=Bug_report.mdphpstan-bot commentedon Oct 4, 2021
@ekisu After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
schlndh commentedon Oct 20, 2023
@ondrejmirtes This issue can be closed.
Regression tests
github-actions commentedon Dec 4, 2023
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.