Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters

From: Date: Mon, 12 Mar 2012 21:50:58 +0000
Subject: Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.internals 
Request: Send a blank email to internals+get-58896@lists.php.net to get a copy of this message
On 2012-03-12, Arvids Godjuks <arvids.godjuks@gmail.com> wrote: > --f46d0442880e02b97f04bb0b432b > Content-Type: text/plain; charset=UTF-8 > > I think that the "null issue" is not an issue. Strictly speaking if you > want null or an int - leave out the type hint and use generic argument that > will accept anything. > I think it's over-engineering to try and push a special treatment for the > null. If function/method argument accepts anything but a single type - > it's type-less and does not need a type hint. However, that conflicts with how typehints work currently in PHP: public function setContainer(Container $container = null) { $this->container = $container; } This is perfectly valid currently, and allows "unsetting" a value easily. I'd expect scalar hints to work exactly the same way -- in other words, null, or a value that satisfies the hint. -- Matthew Weier O'Phinney Project Lead | matthew@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

« previous php.internals (#58896) next »