Re: [RFC] Scalar Type Hinting With Casts (re-opening)

From: Date: Thu, 24 Jul 2014 08:33:24 +0000
Subject: Re: [RFC] Scalar Type Hinting With Casts (re-opening)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-75994@lists.php.net to get a copy of this message
> The argument saying that it is not the PHP way is somehow incorrect > here, given that we already do that for classe. The type jungling > makes sense in implementations, as it always was but argument passing > and validation have been a source of pain since very long. I could > imagine one exception with the "numeric" type, which could accept > anything and got converted to integer/numeric values, like "1235ab" or > other weird things. Personal opinion of a nonvoter, just for the record :) The fact that roughly everybody in the strict-and-validation camp in the recent discussions, adds in a different view on "with the exception of", very very strongly suggests that the strict-and-validation POV is wrong wrong wrong. On the one hand, because calling code will become sprinkled with casts on function calls to coerce the arguments to conform to the strict interpretation. And on the other hand, because validation needs, for all practical purposes, are far more finegrained than any half-a-dozen-type scheme. So, I'm 100% in the cast camp, i.e. interpret scalar type annotation of function arguments as syntactic sugar for explicit casts at the beginning of the function. best regards Patrick

« previous php.internals (#75994) next »