Hi all,

Static callbacks behave differently between 5.2 and 5.3, I recently noticed this when trying to install PEAR, it printed a warning each time call_user_func and call_user_func_array was used.

After some tracking down it seems like the callback option for zend_parse_parameters was backported from 6 but the strict check was left as is.

<?php
class MyClass { function test($var) { echo "$var\n"; } }
MyClass::Test('regular');
call_user_func(array('MyClass', 'test'), 'callback');
?>

The prints E_STRICT errors in PHP 5.2 but in 5.3 you get a single E_STRICT error followed by a warning for call_user_func.

You can resolve this by adding the static keyword to the method declaration but regardless it's inconsistent as stands. I think the strict flag needs to be removed for 5.3.

Patch is attached to resolve the issue.

Scott
Index: ZendEngine2/zend_API.c
===================================================================
RCS file: /repository/ZendEngine2/zend_API.c,v
retrieving revision 1.296.2.27.2.34.2.17
diff -u -r1.296.2.27.2.34.2.17 zend_API.c
--- ZendEngine2/zend_API.c      24 Jan 2008 10:49:26 -0000      
1.296.2.27.2.34.2.17
+++ ZendEngine2/zend_API.c      30 Jan 2008 10:37:45 -0000
@@ -2568,7 +2568,7 @@
        zend_function *func;
        zval **obj;
 
-       if (!zend_is_callable_ex(callable, IS_CALLABLE_STRICT, callable_name, 
NULL, &ce, &func, &obj TSRMLS_CC)) {
+       if (!zend_is_callable_ex(callable, 0, callable_name, NULL, &ce, &func, 
&obj TSRMLS_CC)) {
                return FAILURE;
        }
 

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

Reply via email to