Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25774 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55909 invoked by uid 1010); 20 Sep 2006 19:11:35 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 55893 invoked from network); 20 Sep 2006 19:11:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Sep 2006 19:11:35 -0000 Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.226.6.42 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.226.6.42 darkcity.gna.ch Linux 2.5 (sometimes 2.4) (4) Received: from [195.226.6.42] ([195.226.6.42:48429] helo=mail.gna.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/E3-15260-56291154 for ; Wed, 20 Sep 2006 15:11:34 -0400 Received: from localhost (localhost [127.0.0.1]) by darkcity.gna.ch (Postfix) with ESMTP id 21002C4D07 for ; Wed, 20 Sep 2006 21:11:30 +0200 (CEST) Received: from unknown by localhost (amavisd-new, unix socket) id client-XXb54Qtv for ; Wed, 20 Sep 2006 21:11:28 +0200 (CEST) Received: from [192.168.1.72] (unknown [195.226.9.186]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTP id E7B43C4CFC for ; Wed, 20 Sep 2006 21:11:27 +0200 (CEST) Message-ID: <4511925F.5060602@cschneid.com> Date: Wed, 20 Sep 2006 21:11:27 +0200 User-Agent: Thunderbird 1.5.0.7 (X11/20060911) MIME-Version: 1.0 To: PHP Developers Mailing List Content-Type: multipart/mixed; boundary="------------060305010409000702010601" X-Virus-Scanned: amavisd-new at gna.ch Subject: Parameter checking in 5.2 From: cschneid@cschneid.com (Christian Schneider) --------------060305010409000702010601 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit In the discussion about parameter checking in 5.2 I proposed to relax the checks a tiny little bit: Don't test static functions (e.g. useful for factory methods) and allow adding default values to functions (the object of the inherited class still accepts the same parameters as the base class). A patch is attached. Example: class Base { static function factory($x) { } function foo($x) { } } class Spezialized extends Base { static function factory() { } # Static method, e.g. factory method function foo($x = null) { } # Default values for specialized class } Regards, - Chris --------------060305010409000702010601 Content-Type: text/plain; name="param_mismatch.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="param_mismatch.patch.txt" Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.647.2.27.2.18 diff -u -r1.647.2.27.2.18 zend_compile.c --- Zend/zend_compile.c 19 Sep 2006 21:36:53 -0000 1.647.2.27.2.18 +++ Zend/zend_compile.c 20 Sep 2006 19:05:43 -0000 @@ -1922,13 +1922,12 @@ } /* 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)) { + if ((fe->common.fn_flags & (ZEND_ACC_CTOR | ZEND_ACC_STATIC)) && !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) { return 1; } /* check number of arguments */ - if (proto->common.required_num_args != fe->common.required_num_args - || proto->common.num_args > fe->common.num_args) { + if (proto->common.num_args > fe->common.num_args) { return 0; } --------------060305010409000702010601--