https://www.php.net/manual/en/function.defined.php
The same could be said for class_exists, function_exists, method_exists etc.
https://www.php.net/manual/en/function.class-exists.php
This would be a way of controlling false diagnostics using PHP code rather than relying on non-standard @suppress or @noinspect phpdoc annotations.
assert(class_exists('Foo'));
class_exists will suppress also method calls to this class? Idea is interesting, but will result for sure with angry bug reports :) I mean, following example is ridicules and probably @suppress/@noinspect would be way better.
function a():void{
assert(class_exists('Foo'));
$f = new Foo;
assert(method_exists('Foo', 'test'));
$f->test();
}
Just as example psalm assumes mixed in such cases https://psalm.dev/r/a5a6a62123 (and can't deal with this example)
class_exists, rand
Send error "undefined function" because this occurs?
@LeninZapata no, if you are seeing errors on these then it is unrelated. Please open a new ticket and include the settings you are using.
This error flag is clearly wrong:
![]()
any news on this?
Same problem when working with WooCommerce and using the contant WOOCOMMERCE_VERSION.
any progress??
@bmewburn any updates?
Most helpful comment
This error flag is clearly wrong: