Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8132 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12833 invoked by uid 1010); 25 Feb 2004 23:39:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12791 invoked from network); 25 Feb 2004 23:39:01 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.176) by pb1.pair.com with SMTP; 25 Feb 2004 23:39:01 -0000 Received: from [212.227.126.206] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Aw8cH-0003Yj-00 for internals@lists.php.net; Thu, 26 Feb 2004 00:39:01 +0100 Received: from [80.139.1.157] (helo=[80.139.1.157]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1Aw8cG-0007ns-00 for internals@lists.php.net; Thu, 26 Feb 2004 00:39:00 +0100 To: internals@lists.php.net In-Reply-To: <1077749539.685.27.camel@localhost> References: <1077748616.685.16.camel@localhost> <1781292779406.20040225234401@marcus-boerger.de> <1077749539.685.27.camel@localhost> Content-Type: multipart/mixed; boundary="=-hisG3gNKwmE/tYs8iZk6" Message-ID: <1077752071.685.57.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Thu, 26 Feb 2004 00:34:31 +0100 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:e958292ea7b1c44e51b2b9ca0a9da460 Subject: Re: [PHP-DEV] Declaration of Bar::__construct() must be compatible with that of Foo::__construct() From: thekid@thekid.de (Timm Friebe) --=-hisG3gNKwmE/tYs8iZk6 Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, 2004-02-25 at 23:52, Timm Friebe wrote: > On Wed, 2004-02-25 at 23:44, Marcus Boerger wrote: > > Hello Timm, > > > > i had the same expirience today too. And also for me it makes not much > > sense. The constructor shouldn't check inheritance rules. > > Neither should other methods follow this. What if I want to add a > non-default parameter to an overriden method? Some test cases: Should work #1, Bar::connect() adds an argument ------------------------------------------------------------------- Should work #2, Bar::connect() might contain something such as parent::connect('foo.example.com'); ------------------------------------------------------------------- Should work #3, Bar::connect() might contain something such as parent::connect($dsn->getHost()); ------------------------------------------------------------------- Should work #4, Foo::connect() adds a default argument ------------------------------------------------------------------- Should work #5, both interface and implementer have a default value for the argument "server" ------------------------------------------------------------------- Should work #6, implementation adds a default value ------------------------------------------------------------------- Should NOT work #1, Foo doesn't fully implement connect() ------------------------------------------------------------------- Should NOT work #2, class / primitive clash on argument ------------------------------------------------------------------- Should NOT work #3, Foo implements Connector::connect() incorrectly ------------------------------------------------------------------- Should NOT work #4, Foo implements Connector::connect() incorrectly ------------------------------------------------------------------- I would simply refrain from calling zend_do_perform_implementation_check() in inheritance. - Timm --=-hisG3gNKwmE/tYs8iZk6 Content-Disposition: attachment; filename=zend_compile.diff Content-Type: text/x-patch; name=zend_compile.diff; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.547 diff -u -r1.547 zend_compile.c --- Zend/zend_compile.c 25 Feb 2004 17:23:50 -0000 1.547 +++ Zend/zend_compile.c 25 Feb 2004 23:23:42 -0000 @@ -1733,7 +1733,7 @@ return 0; } - for (i=0; i < proto->common.num_args; i++) { + for (i = 0; i < proto->common.num_args; i++) { if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)) { /* Only one has a type hint and the other one doesn't */ return 0; @@ -1828,8 +1828,11 @@ } } - if (!zend_do_perform_implementation_check(child)) { - zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name); + /* Perform implementation check when implementing an interface */ + if (child->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE) { + if (!zend_do_perform_implementation_check(child)) { + zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name); + } } return 0; --=-hisG3gNKwmE/tYs8iZk6--