We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi!
Getting this:
TypeDoesNotContainType : 'Closure' cannot be identical to class-string<callable-object>
How so? Closure is a class-string. And an instance of Closure is a callable and an object.
Closure
class-string
callable
object
Or no?
The text was updated successfully, but these errors were encountered:
I found these snippets:
<?php function isWhatever (callable $callable): bool { return is_object($callable) && get_class($callable) === 'Closure'; }
Psalm output (using commit 08afc45): ERROR: TypeDoesNotContainType - 5:37 - 'Closure' cannot be identical to class-string<callable-object>
Sorry, something went wrong.
Add a Psalm baseline file
6b0fb67
This suppresses a bunch of errors en-masse. They are very difficult to satisfy. See also vimeo/psalm#10922
Hey @XedinUnknown,
Closure is a not a class-string in this case, because it is written as a string 'Closure’.
'Closure’
You can use \Closure::class instead.
\Closure::class
https://psalm.dev/r/276a6dafc9
<?php function isWhatever (callable $callable): bool { return is_object($callable) && $callable instanceof Closure; } function isWhatever2(callable $callable): bool { return is_object($callable) && get_class($callable) === \Closure::class; }
Psalm output (using commit 08afc45): No issues!
No branches or pull requests
Hi!
Getting this:
How so?
Closure
is aclass-string
. And an instance ofClosure
is acallable
and anobject
.Or no?
The text was updated successfully, but these errors were encountered: