Skip to content

Conversation

@jderusse
Copy link
Member

This PR asserts that enums returned by the API are wellknown values. Otherwise it fallback to the UNKNOWN_TO_SDK generic value.

In that way, we respect the contract when saying methods returns a FooEnum::*.

Side note: We still have to keep the psalm exceptions, because psalm can not infer the type of Enum::exists($value) ? $value : Enum:FALLBACK to Enum::*.

see https://psalm.dev/r/518a0924fe

We would need an equivalent of typescript's is keyword https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates

fix #1921

@jderusse jderusse force-pushed the unknown-enum branch 4 times, most recently from bb38eb9 to 1d991a6 Compare November 27, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better handling of unknown enum values in responses

1 participant