Is it possible to treat implicit mixed same way as explicit mixed? #7835
Replies: 3 comments 3 replies
-
|
You can add the mixed type with a docblock: https://phpstan.org/r/293a7933-529a-4a09-bac0-130040dae788 |
Beta Was this translation helpful? Give feedback.
-
|
@ondrejmirtes I did some digging int PHPStan internals and it seems there is no way to check implicit mixed. But it looks like it would be quite easy to add in similar way as checkExplicitMIxed is handled in https://github.com/phpstan/phpstan-src/blob/f1fd385433480f87bdda1d7d8ff6887e25f003ba/src/Rules/RuleLevelHelper.php Do you have plans to add it? Should I try to draft PR for it? |
Beta Was this translation helpful? Give feedback.
-
|
PR with checkImplicitMixed is ready phpstan/phpstan-src#1645 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I just got bitten by bug caused by passing null to function that requires string:
It is in legacy code that is not yet fully type hinted so lots of implicit mixed is still there.
I would like to check for similar errors but it seems even on level 9 PHPStan ignores passing implicit mixed to parameter requiring string. When I add explicit mixed to parameter it is reported but but not with implicit mixed.
Is there any way to treat implicit mixed as explicit mixed in these cases?
Beta Was this translation helpful? Give feedback.
All reactions