- Issue created by @tr
- Merge request !91Issue #3499276 by tr: phpstan: Variable $event might not be defined. β (Merged) created by tr
Automatically closed - issue fixed for 2 weeks with no activity.
This phpstan warning is triggered twice in on of our tests. It's basically a false positive. We have a required radios form element, which must return one of three choices and nothing else. Then there's a switch statement that assigns $event does differently for each choice choice. The phpstan warning is because phpstan thinks the $event variable will not be set if the choice is anything other than the three choices, which is true but that can never happen. And there is no reasonable default value for $event.
A workaround is to use a match() statement instead of a switch. It's a little less clear IMO, but it should eliminate the warning, which will make the tests easier to maintain.
Active
4.0
Rules Core
Automatically closed - issue fixed for 2 weeks with no activity.