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

From: Date: Sun, 13 Jul 2014 15:36:05 +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-75419@lists.php.net to get a copy of this message
On 13/07/2014 06:22, Stas Malyshev wrote:
I have one request: could we please stop calling it "hinting"?
I've always thought the current "type hinting" should be called "type assertion", since passing the wrong data type is detected only at runtime, and causes an error in much the same way as if you wrote assert($param instanceof HintedClass). What this RFC proposes is more like "type validation" - detecting that the given input can be safely coerced to the given type, and performing the coercion in the process. As Andrea points, out, it's similar to what Nikita called[1] "strict weak type hinting", but with the added step of performing the cast, which is really just a convenience, since if you've asked for a value to be validated as an int, you're presumably about to use it as one. [1] http://nikic.github.io/2012/03/06/Scalar-type-hinting-is-harder-than-you-think.html -- Rowan Collins [IMSoP]

Thread (250 messages)

« previous php.internals (#75419) next »