Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Dec 7, 2025

$type->toArrayKey() instanceof ErrorType is not the right check cause true, false, 1.0, null, ... are ignored by the function. It has to be an int or a string.

And numeric string wasn't casted into int when used as array key.

@staabm
Copy link
Contributor

staabm commented Dec 7, 2025

Looks like it should be $allowedValues->isSuperTypeOf(...)

@VincentLanglet
Copy link
Contributor Author

Looks like it should be $allowedValues->isSuperTypeOf(...)

How you deal with something like "int|null" ?
I dont see the benefit with keeping the unionType check and calling filterType on it rather than doing an intersection like I did.

@staabm
Copy link
Contributor

staabm commented Dec 7, 2025

I see now, that you also need the normalized result. its not just a check for compatibility. my suggestion did not fit that.

@mad-briller
Copy link
Contributor

good catches, didn't think to try other scalar types πŸ‘

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.

3 participants