On 3/10/2017 11:57 AM, Andrey Andreev wrote: > Yes, they're valid string values, but the examples I gave were meant > to show that context can make them predictably invalid, and hence why > strict typing is desirable.
I am totally in favor of strict types, but having a union of some type and having the ability to constraint to it is strict. The union of bool|int|float|null|string is stricter than the super type mixed. That's the whole point of having a stringable. You can more clearly communicate what you require to do your work. Once more, it does not matter what the caller give you, you need to validate it no matter what. On 3/10/2017 4:11 PM, Andrey Andreev wrote: > You don't, but I do care at times. Sorry, but your example makes no sense at all. Just because you got an int does not even remotely mean that one of those constants was used. On top of that all, you still need to validate the int you got because it has 2^31-1 possible states, or more in case of 64bit. You need an enum in such a case, and that's the only thing that helps, nothing else. It is also inherently simple to create one, and be type safe forever. -- Richard "Fleshgrinder" Fussenegger -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php