-
Notifications
You must be signed in to change notification settings - Fork 659
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
if ($enum instanceof BackedEnum)
doesn't infer BackedEnum
type
#10585
Comments
I found these snippets: https://psalm.dev/r/48ec6feed1<?php
interface Operator {}
enum Foo: string implements Operator
{
case bar = 'bar';
}
function fun(Operator $operator) :string|int
{
if ($operator instanceof BackedEnum) {
// $operator is Operator&BackedEnum but psalm triggers NoInterfaceProperties error
return $operator->value;
}
return '';
}
function fun1(BackedEnum $operator) :string|int
{
return $operator->value;
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BackedEnum always have the properties
name
andvalue
. In the context of a method attribute with a type, usinginstanceof BackedEnum
doesn't infer the type.https://psalm.dev/r/48ec6feed1
The text was updated successfully, but these errors were encountered: