3 ms·
It would be nice if you had an option, like function foo(weak int $i) for weak type hinting, and function foo(int $i) for strict. The arguments for we
by krapp 13y ago
It would be nice if you had an option, like
function foo(weak int $i)
for weak type hinting, and
function foo(int $i)
for strict. The arguments for weak type hinting make sense but sometimes you don't want any ambiguity.
- ciarand 13y agoYeah, 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.
- kijin 13y agoOr 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".