Re: BC fix for __call definition. (Bug #29716) + pear bug #2136

From: Date: Thu, 19 Aug 2004 20:51:50 +0000
Subject: Re: BC fix for __call definition. (Bug #29716) + pear bug #2136
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-12272@lists.php.net to get a copy of this message
I actually don't think it's the right approach. ext/overload has always been experimental and it doesn't make sense to start putting such a hack into the engine. You can easily change the code to use conditional includes and therefore, your PHP 4 version won't be compiled under PHP 5. Do you know how many PEAR classes are actually affected by this? Andi At 08:58 PM 8/19/2004 +0800, Alan Knowles wrote:
Attached (hopefully) should be a fix for bug #29716, allowing 3 arguments for __call, but emitting a E_STRICT error. This is needed to enable simple BC wrappers to be written for code wanting to use overload in PHP4. BTW: Notes on current CVS flex 2.5.31 currently reports flex: fatal internal error, bad line in skeleton file flex 2.5.4: works OK (debian package flex-old) /ext/standard/unserializer.c needs touching, otherwise re2c tries to generate it (and fails here) Zeev/Andi could you OK it?, marcus is ok with the principle (although he hasnt seen the code) Regards Alan ? fix_29716.txt ? nestfix.diff Index: zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.578 diff -u -r1.578 zend_compile.c
--- zend_compile.c      15 Aug 2004 15:48:32 -0000      1.578
+++ zend_compile.c      19 Aug 2004 12:44:40 -0000
@@ -1113,8 +1113,14 @@
                        zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 1 argument", CG(active_class_entry)->name, ZEND_GET_FUNC_NAME);
                } else if (name_len == sizeof(ZEND_SET_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) && CG(active_op_array)->num_args != 2) {
                        zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 2 arguments", CG(active_class_entry)->name, ZEND_SET_FUNC_NAME);
-               } else if (name_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) && CG(active_op_array)->num_args != 2) {
-                       zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 2 arguments", CG(active_class_entry)->name, ZEND_CALL_FUNC_NAME);
+               } else if (name_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME))) {
+                       /* we allow 3 arguments to enable BC wrappers for PHP4 __call() */
+                       int num_args = CG(active_op_array)->num_args;
+                       if ((num_args != 2) && (num_args != 3)) {
+                               zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 2 arguments", CG(active_class_entry)->name, ZEND_CALL_FUNC_NAME);
+                       } else if (num_args == 3) {
+                               zend_error(E_STRICT, "Method %s::%s() should take exactly 2 arguments", CG(active_class_entry)->name, ZEND_CALL_FUNC_NAME);
+                       }
                }
        } else {
                if (name_len == sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)) && CG(active_op_array)->num_args != 1) {
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#12272) next »