-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

+1

Given that static methods apply to the class and don't have much in the
way of inheritance rules, Christian's suggested behaviour makes a lot of
sense.

Jasper

Christian Schneider wrote:
> 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;
>       }
>  
> 
> 

- --
Jasper Bryant-Greene
Director
Album Limited

[EMAIL PROTECTED]
+64 21 708 334 / 0800 425 286
http://www.album.co.nz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5-ecc0.1.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iFcDBQFFEfIqnqZ4vwo6v1gRCrP0AP4iqczaBXNYGTtooXvP8AKcfwS1tlfHghVa
U4EWSFsIMQD/eoAnLN9JeJaqFqIqfttF2Pq4TR1GLHkJdowFKZY7vgc=
=DSys
-----END PGP SIGNATURE-----

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

Reply via email to