| > To be honest, I'm completely in the strict camp Can you explain why? Are you using PHP in a web context? Because everything from the web is a string. So wouldn't it make the most sense to let the functions using the web data coerce to integer, and just work? How does putting (int) before the arguments to function help anything? I actually liked Ze'ev's proposal because it let you be weak while making sure you did not coerce obviously bad data. Anyway, as a member of the strong camp, can you explain? |
I would start by saying that everything, regardless of domain, is just a stream of bits. Which is completely useless, just like your assertion.
And I know what you meant, but you're also wrong. A JSON object is only a string before being interpreted. An x-www-form-urlencoded is actually a map in which values can be arrays instead of primitives. Such forms often correspond to domain models with a clear definition.
There's also no such thing as "obviously bad data". All data is good in the proper context, therefore automatic conversions that try to make this distinction do not make sense. I don't necessarily know how PHP behaves, but in another popular language there's a world of difference between "077" and "77". There's also a world of difference between integer, floating point and fixed point and the details are never irrelevant.