Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58896 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49263 invoked from network); 12 Mar 2012 21:50:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2012 21:50:58 -0000 X-Host-Fingerprint: 208.107.13.98 host-98-13-107-208.midco.net Date: Mon, 12 Mar 2012 16:50:58 -0500 Received: from [208.107.13.98] ([208.107.13.98:5653] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/37-13375-1CF6E5F4 for ; Mon, 12 Mar 2012 16:50:58 -0500 Message-ID: <91.37.13375.1CF6E5F4@pb1.pair.com> To: internals@lists.php.net References: User-Agent: slrn/pre1.0.0-18 (Linux) X-Posted-By: 208.107.13.98 Subject: Re: [PHP-DEV] [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters From: weierophinney@php.net (Matthew Weier O'Phinney) On 2012-03-12, Arvids Godjuks 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