Newsgroups: php.cvs,php.internals Path: news.php.net Xref: news.php.net php.cvs:62979 php.internals:48985 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26789 invoked from network); 28 Jun 2010 18:39:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2010 18:39:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:40965] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/D2-09012-24CE82C4 for ; Mon, 28 Jun 2010 14:38:59 -0400 Received: by bwz19 with SMTP id 19so143002bwz.29 for ; Mon, 28 Jun 2010 11:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=R97BcjQkqTSM2knFOTCWepS1gnt/scpSrsCwCs23qyw=; b=romj2ntzfp9QmAdJjUzKbGdKCYnIwMXncsCT4XzfzoCmTPYpPnvjZSP7kcQEAggzXE XcuqTYNRy1Zz+ihdmM9QtlUjIILNYh55U2FeHDdlb7lGyWwsI8GNexjjkUKDoou48vKV ha1vQlmUPu8s89hbsmaI0AmD7rkX/uaGASF9o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; b=VKbmMJFwN7MQkWS65CpXaz+MU6jB+X1fElHEPf0sQBfHIwu6XJcOzhBTgX5p3Bty7W 4KkCR5nPuah3h2mmOtDLTIjXF2GmVrTnBruegNkpYHXZovjHTco19aysBFdmy5zDhkHc J3ihmyIebfys9iejlADpFwKDUqWf720gzwg60= MIME-Version: 1.0 Received: by 10.204.160.134 with SMTP id n6mr3894829bkx.0.1277750328861; Mon, 28 Jun 2010 11:38:48 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.204.59.206 with HTTP; Mon, 28 Jun 2010 11:38:48 -0700 (PDT) Date: Mon, 28 Jun 2010 20:38:48 +0200 X-Google-Sender-Auth: nghn6WTvJ9w2oDy0nnfGDN4PgrY Message-ID: To: Stas Malyshev Cc: =?ISO-8859-1?Q?Johannes_Schl=FCter?= , Felipe Pena , "php-cvs@lists.php.net" , PHP internals list Content-Type: multipart/alternative; boundary=0015175d033476a433048a1b6ee7 Subject: Re: [PHP-CVS] Re: [PHP-DEV] Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/Zend/tests/bug51421.phpt branches/PHP_5_2/Zend/zend_compile.c branches/PHP_5_3/Zend/tests/bug51421.phpt branches/PHP_5_3/Zend/zend_compile.c trunk/Zend/tests/bug51421.phpt From: webmaster@colder.ch (Etienne Kneuss) --0015175d033476a433048a1b6ee7 Content-Type: text/plain; charset=ISO-8859-1 Hi, On Mon, Jun 28, 2010 at 20:17, Stas Malyshev wrote: > Hi! > > 1) arguments can be gathered dynamically in the function, using >> func_get_args. For that reason, PHP gracefully allow a call with too many >> arguments. >> > > Isn't it the case today? > It's the case at the time of the calls. But not when overriding a method: class A { public function foo($a) { } } class B extends A { public function foo() {} } is considered invalid, but $obj->foo($arg); would be perfectly valid for both objects. > Maybe also we can add some syntax like: > function foo($a, $b, ...) - where ... means "I'll deal with those arguments > myself, ignore any compatibility checks" so if the prototype is > foo($a,$b,$c) $a and $b would be checked but not $c and the function is > considered to have enough args. > I'd find that syntax pretty explicit and easy to understand, it wouldn't break any BC. > > 2) a child method should be allowed to define type hints in a >> contra-variant >> manner (currently, it's invariant) >> > > This needs to be fixed. > > 3) a child method should be allowed to return a ref even if the parent >> method is not defined to do so. (returning a ref is an additional >> constraint, and following co-variance of return values, it should be >> allowed). The basic example of this annoyance is: abstract class A >> implements ArrayAcces { public function&__offsetGet($name) { ... } } >> > > This needs to be fixed too. > > 4) all in all: it shouldn't throw a fatal error, those are not critical >> situations for the engine. >> > > I'd say in general OO part of PHP seems to be much more strict and > Java-like than the rest. I'm not sure it's good. I'd demote all situations > where the engine has a way to proceed to at least warning level. > I don't believe that any of those checks causes difficulty for the engine, especially considering that internal classes can pretty much to what they want anyway. > > I'd like to propose to relax such checks, by either allowing more (e.g. 1, >> 2 >> and 3) which can be painful and complicated, or simply removing those >> checks. >> > > I think we shouldn't remove them - we should fix them. It doesn't seem to > be too hard, IMHO. > Enforcing contra-variance can become a tad bit tricky when it comes to: 1) argument vs no argument 2) argument with/without null as default value 3) by ref or not (with/without default values) We should probably specify it formally in which case a prototype is accepted, and then see what needs to be fixed. Also, checking for subtyping in PHP is O(n) which is "slow", but I don't believe it's a concern big enough to change the way we implement "instanceof". Best, -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > -- Etienne Kneuss http://www.colder.ch --0015175d033476a433048a1b6ee7--