Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41161 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40835 invoked from network); 16 Oct 2008 18:12:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Oct 2008 18:12:25 -0000 Authentication-Results: pb1.pair.com header.from=mls@pooteeweet.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mls@pooteeweet.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pooteeweet.org from 88.198.8.16 cause and error) X-PHP-List-Original-Sender: mls@pooteeweet.org X-Host-Fingerprint: 88.198.8.16 bigtime.backendmedia.com Linux 2.6 Received: from [88.198.8.16] ([88.198.8.16:45793] helo=bigtime.backendmedia.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/9D-12818-70487F84 for ; Thu, 16 Oct 2008 14:12:24 -0400 Received: from localhost (unknown [127.0.0.1]) by bigtime.backendmedia.com (Postfix) with ESMTP id A7AAE4144058; Thu, 16 Oct 2008 18:13:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at backendmedia.com Received: from bigtime.backendmedia.com ([127.0.0.1]) by localhost (bigtime.backendmedia.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lygc1f1YRvuY; Thu, 16 Oct 2008 20:13:58 +0200 (CEST) Received: from [192.168.0.151] (77-58-144-136.dclient.hispeed.ch [77.58.144.136]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: mls@pooteeweet.org) by bigtime.backendmedia.com (Postfix) with ESMTP id DC5BA4144009; Thu, 16 Oct 2008 20:13:55 +0200 (CEST) Cc: internals@lists.php.net Message-ID: <5E49B9A3-128A-4C96-875A-A3A8B5BA0C87@pooteeweet.org> To: Nathan Nobbe In-Reply-To: <7dd2dc0b0810071259w438223d1x522feacda511908b@mail.gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Date: Thu, 16 Oct 2008 20:11:42 +0200 References: <7dd2dc0b0810071259w438223d1x522feacda511908b@mail.gmail.com> X-Mailer: Apple Mail (2.929.2) Subject: Re: [PHP-DEV] type hint semantics; disagreement between phpt and manual From: mls@pooteeweet.org (Lukas Kahwe Smith) On 07.10.2008, at 21:59, Nathan Nobbe wrote: > hi all, > > we are encountering an error in our code due to type hint > semantics. php is > allowing NULL values through a type hint for a class, however, if i > read the > manual, NULL, should only be allowed, if and only if, null is given > as the > default value for the formal parameter that is type-hinted. > > "PHP 5 introduces Type Hinting. Functions are now able to force > parameters > to be objects (by specifying the name of the class in the function > prototype) or arrays (since PHP 5.1). However, if > NULLis used as > the default parameter value, it will be allowed as an argument > for any later call." > > now, i have checked our code; there is no NULL default value, and > there are > no parents which mark a default value of NULL. so why would they be > creeping through then.. ? > > well, i glanced at the phpt test, and its quite clear the tests are > allowing > NULL, > > Zend/tests/errmsg_013.phpt:errmsg: default value for parameters with > array > type hint can only be an array or NULL > Zend/tests/errmsg_013.phpt:Fatal error: Default value for parameters > with > array type hint can only be an array or NULL in %s on line %d > > looking at the function prototype in this test, NULL is not > specefied as the > default value, so i dont think NULL should be allowed here anyway.. > --TEST-- > errmsg: default value for parameters with array type hint can only > be an > array or NULL > --FILE-- > > class test { > function foo(array $a = "s") { > } > } > > echo "Done\n"; > ?> > --EXPECTF-- > Fatal error: Default value for parameters with array type hint can > only be > an array or NULL in %s on line %d > > this taken from 5.2.6.RC3 source. it seems to me, either the source > or the > manual is wrong, but which one is it ?? personally, i would prefer > it be > the former in this case ;) > > FWIW, we are currently running php5.2.2 on centos5, but im pretty > sure an > upgrade to 5.2.6 will not change the semantics, since the phpt tests > were > the same in both the 5.2.2 & 5.2.6 source. please file a bug report with a reproduceble test case that illustrates the conflicting behavior with the manual. regards, Lukas Kahwe Smith mls@pooteeweet.org