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
Type inferrence with negated condition with OR #4466
Comments
I found these snippets: https://psalm.dev/r/b09d68b1ed<?php
function specifyString(string $className): void{
if (! (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false))) {
return;
}
/** @psalm-trace $className */;
new ReflectionClass($className);
}
|
This seems to be partially caused by wrong handling for autoloader flag for these functions: https://psalm.dev/r/3313a99852 |
I found these snippets: https://psalm.dev/r/3313a99852<?php
function specifyString(string $className): void{
if (!class_exists($className, false)) {
// class does not exist or is not loaded
return;
}
/** @psalm-trace $className */;
// class exists and is loaded, but Psalm still complain
new ReflectionClass($className);
}
|
Short-circuiting behaviour of |
I found these snippets: https://psalm.dev/r/750ff3309a<?php
function specifyString(string $className): void{
if (! (class_exists($className, true) || interface_exists($className, true) || trait_exists($className, true))) {
return;
}
// expected: class-string|trait-string
/** @psalm-trace $className */;
new ReflectionClass($className);
}
|
I'm gonna say, with the |
@muglug https://psalm.dev/r/3313a99852 is clearly wrong though, isn't it? And it doesn't involve |
I found these snippets: https://psalm.dev/r/3313a99852<?php
function specifyString(string $className): void{
if (!class_exists($className, false)) {
// class does not exist or is not loaded
return;
}
/** @psalm-trace $className */;
// class exists and is loaded, but Psalm still complain
new ReflectionClass($className);
}
|
Yeah, that should be negatable |
Thanks! |
Hi,
In the example below, I'd have expected the type to be
trait-string|class-string
https://psalm.dev/r/b09d68b1ed
Thanks
The text was updated successfully, but these errors were encountered: