Newsgroups: php.cvs,php.internals Path: news.php.net Xref: news.php.net php.cvs:62973 php.internals:48979 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27206 invoked from network); 28 Jun 2010 10:39:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jun 2010 10:39:59 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass 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:35707] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/93-06774-BFB782C4 for ; Mon, 28 Jun 2010 06:39:58 -0400 Received: by bwz19 with SMTP id 19so446378bwz.29 for ; Mon, 28 Jun 2010 03:39:52 -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=96F5276ga+FbFagUnQKz0Ix5igylLEqV0P8AGXKYwXo=; b=DRHPJuWVaQYrmSCjdzu862O2Ap6WcrrEeDxTGsW70JSMWV0ebb10q/TsH//d0TCkfs +7EIygGes+L2JGwfuqCGWaymAlpY7stp28qtIMrKX22/b/gk5v7uXaCV/k6mPjoXvfpu Cyzc1V5uR4MP89ikvfLytnrc7ZZL89MPApfDQ= 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=S78VXs3oqcY8UFMW+Ldj2f9tYBe3EbL3rfr1ZNa3vX8YBM5o+sCfGe+8u8jYBh931K C41UoFTfdjhgSyldPOezWj5rpSHDIQgZIznbACqkBtaM+CKJX6gHwOtPvHIFXxQnk/Uw ZOmkq4q7iFPpAiPi5WhQaMQBAn83WdQuBMWZE= MIME-Version: 1.0 Received: by 10.204.160.134 with SMTP id n6mr3415739bkx.0.1277721590556; Mon, 28 Jun 2010 03:39:50 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.204.59.206 with HTTP; Mon, 28 Jun 2010 03:39:50 -0700 (PDT) Date: Mon, 28 Jun 2010 12:39:50 +0200 X-Google-Sender-Auth: kPQ9oWVXoA2viugGHPpc1nePkIw Message-ID: To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: Felipe Pena , php-cvs@lists.php.net, PHP internals list Content-Type: multipart/alternative; boundary=0015175d033486ea2e048a14bd72 Subject: 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 trunk/Zend/zen From: webmaster@colder.ch (Etienne Kneuss) --0015175d033486ea2e048a14bd72 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, 2010/6/28 Johannes Schl=FCter > Hi, > > On Sat, 2010-06-26 at 22:05 +0000, Felipe Pena wrote: > > felipe Sat, 26 Jun 2010 22:05:13 +000= 0 > > > > Revision: http://svn.php.net/viewvc?view=3Drevision&revision=3D300770 > > > > Log: > > - Fixed bug #51421 (Abstract __construct constructor argument list not > enforced) > > > > Bug: http://bugs.php.net/51421 (Closed) Abstract __construct constructo= r > argument list not enforced > > Won't this break compatibility? > > I'd say the change is logically correct but not sure we should break BC > there during RC. > At the risk of starting some political debate, I believe that the current state of prototype checks make close to no sense in PHP, for 4 reasons: 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. 2) a child method should be allowed to define type hints in a contra-varian= t manner (currently, it's invariant) 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) { ... } } 4) all in all: it shouldn't throw a fatal error, those are not critical situations for the engine. 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. Best, > > johannes > > > Changed paths: > > A php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt > > U php/php-src/branches/PHP_5_2/Zend/zend_compile.c > > A php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt > > U php/php-src/branches/PHP_5_3/Zend/zend_compile.c > > A php/php-src/trunk/Zend/tests/bug51421.phpt > > U php/php-src/trunk/Zend/zend_compile.c > > > > Added: php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt > (rev 0) > > +++ php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt 2010-06-2= 6 > 22:05:13 UTC (rev 300770) > > @@ -0,0 +1,18 @@ > > +--TEST-- > > +Bug #51421 (Abstract __construct constructor argument list not enforce= d) > > +--FILE-- > > + > + > > +class ExampleClass {} > > + > > +abstract class TestInterface { > > + abstract public function __construct(ExampleClass $var); > > +} > > + > > +class Test extends TestInterface { > > + public function __construct() {} > > +} > > + > > +?> > > +--EXPECTF-- > > +Fatal error: Declaration of Test::__construct() must be compatible wit= h > that of TestInterface::__construct() in %s on line %d > > > > > > Property changes on: > php/php-src/branches/PHP_5_2/Zend/tests/bug51421.phpt > > ___________________________________________________________________ > > Added: svn:keywords > > + Id Rev Revision > > Added: svn:eol-style > > + native > > > > Modified: php/php-src/branches/PHP_5_2/Zend/zend_compile.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- php/php-src/branches/PHP_5_2/Zend/zend_compile.c 2010-06-26 21:29:= 56 > UTC (rev 300769) > > +++ php/php-src/branches/PHP_5_2/Zend/zend_compile.c 2010-06-26 22:05:= 13 > UTC (rev 300770) > > @@ -2009,13 +2009,20 @@ > > { > > zend_uint i; > > > > - /* If it's a user function then arg_info =3D=3D NULL means we don= 't > have any parameters but we still need to do the arg number checks. We ar= e > only willing to ignore this for internal functions because extensions don= 't > always define arg_info. */ > > + /* If it's a user function then arg_info =3D=3D NULL means we don= 't > have any parameters but > > + * we still need to do the arg number checks. We are only willin= g > to ignore this for internal > > + * functions because extensions don't always define arg_info. > > + */ > > if (!proto || (!proto->common.arg_info && proto->common.type !=3D > ZEND_USER_FUNCTION)) { > > return 1; > > } > > > > - /* Checks for constructors only if they are declared in an > interface */ > > - if ((fe->common.fn_flags & ZEND_ACC_CTOR) && > !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) { > > + /* Checks for constructors only if they are declared in an > interface, > > + * or explicitly marked as abstract > > + */ > > + if ((fe->common.fn_flags & ZEND_ACC_CTOR) > > + && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) = =3D=3D > 0 > > + && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) = =3D=3D > 0)) { > > return 1; > > } > > > > > > Added: php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt > (rev 0) > > +++ php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt 2010-06-2= 6 > 22:05:13 UTC (rev 300770) > > @@ -0,0 +1,18 @@ > > +--TEST-- > > +Bug #51421 (Abstract __construct constructor argument list not enforce= d) > > +--FILE-- > > + > + > > +class ExampleClass {} > > + > > +abstract class TestInterface { > > + abstract public function __construct(ExampleClass $var); > > +} > > + > > +class Test extends TestInterface { > > + public function __construct() {} > > +} > > + > > +?> > > +--EXPECTF-- > > +Fatal error: Declaration of Test::__construct() must be compatible wit= h > that of TestInterface::__construct() in %s on line %d > > > > > > Property changes on: > php/php-src/branches/PHP_5_3/Zend/tests/bug51421.phpt > > ___________________________________________________________________ > > Added: svn:keywords > > + Id Rev Revision > > Added: svn:eol-style > > + native > > > > Modified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2010-06-26 21:29:= 56 > UTC (rev 300769) > > +++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2010-06-26 22:05:= 13 > UTC (rev 300770) > > @@ -2532,13 +2532,20 @@ > > { > > zend_uint i; > > > > - /* If it's a user function then arg_info =3D=3D NULL means we don= 't > have any parameters but we still need to do the arg number checks. We ar= e > only willing to ignore this for internal functions because extensions don= 't > always define arg_info. */ > > + /* If it's a user function then arg_info =3D=3D NULL means we don= 't > have any parameters but > > + * we still need to do the arg number checks. We are only willin= g > to ignore this for internal > > + * functions because extensions don't always define arg_info. > > + */ > > if (!proto || (!proto->common.arg_info && proto->common.type !=3D > ZEND_USER_FUNCTION)) { > > return 1; > > } > > > > - /* Checks for constructors only if they are declared in an > interface */ > > - if ((fe->common.fn_flags & ZEND_ACC_CTOR) && > !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) { > > + /* Checks for constructors only if they are declared in an > interface, > > + * or explicitly marked as abstract > > + */ > > + if ((fe->common.fn_flags & ZEND_ACC_CTOR) > > + && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) = =3D=3D > 0 > > + && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) = =3D=3D > 0)) { > > return 1; > > } > > > > > > Added: php/php-src/trunk/Zend/tests/bug51421.phpt > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- php/php-src/trunk/Zend/tests/bug51421.phpt > (rev 0) > > +++ php/php-src/trunk/Zend/tests/bug51421.phpt 2010-06-26 22:05:= 13 > UTC (rev 300770) > > @@ -0,0 +1,18 @@ > > +--TEST-- > > +Bug #51421 (Abstract __construct constructor argument list not enforce= d) > > +--FILE-- > > + > + > > +class ExampleClass {} > > + > > +abstract class TestInterface { > > + abstract public function __construct(ExampleClass $var); > > +} > > + > > +class Test extends TestInterface { > > + public function __construct() {} > > +} > > + > > +?> > > +--EXPECTF-- > > +Fatal error: Declaration of Test::__construct() must be compatible wit= h > that of TestInterface::__construct() in %s on line %d > > > > > > Property changes on: php/php-src/trunk/Zend/tests/bug51421.phpt > > ___________________________________________________________________ > > Added: svn:keywords > > + Id Rev Revision > > Added: svn:eol-style > > + native > > > > Modified: php/php-src/trunk/Zend/zend_compile.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- php/php-src/trunk/Zend/zend_compile.c 2010-06-26 21:29:56 UTC > (rev 300769) > > +++ php/php-src/trunk/Zend/zend_compile.c 2010-06-26 22:05:13 UTC > (rev 300770) > > @@ -2909,13 +2909,20 @@ > > { > > zend_uint i; > > > > - /* If it's a user function then arg_info =3D=3D NULL means we don= 't > have any parameters but we still need to do the arg number checks. We ar= e > only willing to ignore this for internal functions because extensions don= 't > always define arg_info. */ > > + /* If it's a user function then arg_info =3D=3D NULL means we don= 't > have any parameters but > > + * we still need to do the arg number checks. We are only willin= g > to ignore this for internal > > + * functions because extensions don't always define arg_info. > > + */ > > if (!proto || (!proto->common.arg_info && proto->common.type !=3D > ZEND_USER_FUNCTION)) { > > return 1; > > } > > > > - /* Checks for constructors only if they are declared in an > interface */ > > - if ((fe->common.fn_flags & ZEND_ACC_CTOR) && > !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) { > > + /* Checks for constructors only if they are declared in an > interface, > > + * or explicitly marked as abstract > > + */ > > + if ((fe->common.fn_flags & ZEND_ACC_CTOR) > > + && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) = =3D=3D > 0 > > + && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) = =3D=3D > 0)) { > > return 1; > > } > > > > > > -- > > PHP CVS Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Etienne Kneuss http://www.colder.ch --0015175d033486ea2e048a14bd72--