Post #3905067
2026-07-17 16:04 UTC
What is this?
– if key is string, then value must be int
– if key is int, then value must be bool
It should allow for ['foo' => 1, true]
#AskFedi #FollowerPower #amCoding #amProgramming #softwareDevelopment #softwareEngineering #PHP #PHPStan #computerScience #dataTypes #typeSystem #typeTheory #typeVariance #compositeDataTypes #dataTypeComposition
Replies (1)
-
@gmazzap@phpc.social 2026-07-18 07:15
@shaedrich@mastodon.online It's union. But be careful in PHP: numeric strings are converted to numbers. So ["2" => 2], which in theory fits the type, is not possibile in PHP. The key gets converted to a int and so the value is supposed to be a bool but it is not.