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
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;
        }
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to