Re:Making PHP Safer
by krapp on Friday January 31, 2014 @10:28PM
(#7160728)
It would be nice if you had an option, like
for weak type hinting, and
for strict. The arguments for weak type hinting make sense but sometimes you don't want any ambiguity.
[ Parent
| on HN ]
Or something like "numeric" that allows both int and float, as well as any string that would pass the test of is_numeric(). It would be just like class inheritance: int and float would be treated as subtypes of "numeric".
Yeah, as long as there's a way to specify a strict type then I'd be happy. Libraries and other code that's intended to be used by 3rd parties could probably benefit from weak type hinting, but internally I'd really like the confidence that comes from strict hinting.