Do not report function_exists as always-true conditions#5739
Conversation
staabm
left a comment
There was a problem hiding this comment.
why did it work before this PR when only a single constant string was given to function_exists?
Either phpstan-src/src/Analyser/MutatingScope.php Lines 2159 to 2165 in 1468103 or Should it be simplified/worked ? |
|
that was a great hint, thank you. |
| if (!function_exists($func)) { | ||
| throw new \Exception(); | ||
| } | ||
|
|
||
| funcA(); | ||
| funcB(); |
There was a problem hiding this comment.
in this case, the function_exists() will only assure one of the functions to exist.
therefore - to be defensive - I am using only count($constantStrings) === 1 in the src/Type/Php/FunctionExistsFunctionTypeSpecifyingExtension.php so we still expectedly error about function exists
There was a problem hiding this comment.
Might be worth adding it as a coment in this file ?
Closes phpstan/phpstan#8980
extracted from #5737 which went too far