Prevent false positive on method_exists() and function_exists()#2277
Prevent false positive on method_exists() and function_exists()#2277staabm wants to merge 2 commits intophpstan:1.10.xfrom
method_exists() and function_exists()#2277Conversation
|
Maybe there should be a config switch to enable/disable this rule for function/method_exists? |
|
This pull request has been marked as ready for review. |
There was a problem hiding this comment.
let me propose to not judge about "always exist yes/no", when function_exists() is called on a php-src native/php-extension function - these functions might not exist at runtime and code trying to detect such optional dependency should not get flagged IMO.
wdyt?
going one step further I think it might also make sense to prevent the "always exists yes/no" error for method_exists(), when the class involved is located in the composer vendor/ folder.
the assumption would be that the current project might support different versions of a external dependency and therefore needs to feauture detect the existance of methods.
wdyt?
There was a problem hiding this comment.
@ondrejmirtes do you have a opinion on the above comment?
f98d66a to
e75395a
Compare
|
Should this also account for |
Pre-existing tests have different expectations regarding the "is always true/false" results, then what was discussed in the linked issue.
I wonder when/how we should/can differentiate whether we expect this "is always true/false" error or not.
I just did the trivial version, so we can see how this violates existing expectations and start discussion/feedback from here.
closes phpstan/phpstan#8980