-
-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support function_exists #3576
Comments
Why? What’s the effect of analyzing such function? |
This.
|
Can you show the real code that’s causing this? |
From the link above: if (Bootup::is_php('7.4')) {
/**
* @psalm-suppress ImpureFunctionCall - why?
*/
$return = \mb_str_split($input, $length);
if ($return !== false) {
return $return;
}
} Test fails under PHP 7.3 |
|
I'm not too keen on skipping analysing code like this, but:
I'm gonna keep this open as a feature request for |
Thank you. |
I have a similar issue which maybe would be easier to support: if (!\function_exists('tld_extract')) {
throw new \LogicException(\sprintf(
'The method %s::%s is deprecated and should not longer be used, if you need it you need to install "layershifter/tld-extract". But we recommend as soon as possible update to a newer library like "jeremykendall/php-domain-parser". ',
__CLASS__,
__METHOD__
));
}
return tld_extract($host); |
Whether a 3rd-party function exists is not related to the source code, it comes from the actual PHP environment. Skipping 1 line in analysis could cause an error in run-time. There is something similar in PHPStan: https://phpstan.org/config-reference#constants |
Here is a demo: https://phpstan.org/r/f74cc05e-4fc0-4b58-be29-9caa9b7f31ea |
Implemented: phpstan/phpstan-src@28e8c11 |
Thank you. |
@ondrejmirtes thank you 👍 |
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. |
Support question
How to tell PHPStan to stop analyzing the code inside that conditional?
e.g. https://github.com/voku/portable-utf8/blob/0381b87156c4925e33d497eed05fca5cf5f627e1/src/voku/helper/UTF8.php#L8350-L8358
The text was updated successfully, but these errors were encountered: