You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to be able to take a BackedEnum<string> $enum so that $enum->value is definitely a string. Currently I have false positives because BackedEnum::$value is int|string.
Add template to BackedEnum interface
Add annotation to specify backing type when declaring enum (@enum<int> maybe?)
Check annotation against PHP backing type (can only be string or int, but you can't use @enum<positive-int> with enum Foo: string)
Check annotation against cases (case Bar = 0 should show an issue for @enum<positive-int>)
The BackedEnum template needs to be filled in from the @enum<[type]> annotation so that BackedEnum::from, ::tryFrom, and ::cases use the correct type
The text was updated successfully, but these errors were encountered:
I would think @extends probably? Aren't backed enums implemented as classes extending BackedEnum with a bunch of additional constraints? Looking at this again though you're right that a new annotation for that shouldn't be necessary.
I want to be able to take a
BackedEnum<string> $enum
so that$enum->value
is definitely astring
. Currently I have false positives becauseBackedEnum::$value
isint|string
.BackedEnum
interface@enum<int>
maybe?)string
orint
, but you can't use@enum<positive-int>
withenum Foo: string
)case Bar = 0
should show an issue for@enum<positive-int>
)BackedEnum
template needs to be filled in from the@enum<[type]>
annotation so thatBackedEnum::from
,::tryFrom
, and::cases
use the correct typeThe text was updated successfully, but these errors were encountered: