Re: [RFC] Scalar Type Hints v0.2

From: Date: Thu, 15 Jan 2015 23:16:39 +0000
Subject: Re: [RFC] Scalar Type Hints v0.2
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  Groups: php.internals 
Request: Send a blank email to internals+get-80601@lists.php.net to get a copy of this message
Hi Thomas, > On 15 Jan 2015, at 22:25, Thomas Bley <mails@thomasbley.de> wrote: > > I think the problem with the current rfc is: > > test(42); > function test(string $a) does test((string)$a); > function test(array $a) does not test((array)$a); although casting would be possible. > > So for consistency we might change the syntax or adapt array/object type hints with casting > (BC-break). Having it do an explicit cast would make the feature really dangerous. Explicit casts can’t fail (except for objects, for whatever reason) and so they’ll completely mangle input if it’s bad. Implicit casts can fail. I don’t think this would be a good approach. Thanks. -- Andrea Faulds http://ajf.me/

« previous php.internals (#80601) next »