Re: BC break with callbacks in 5.3

From: Date: Wed, 30 Jan 2008 15:32:20 +0000
Subject: Re: BC break with callbacks in 5.3
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-35030@lists.php.net to get a copy of this message
Marcus, I fully agree that you should add static keywords if you intend to call a method statically, but it's not always possible. Some people are still maintaing a code base that runs in both PHP 4 and 5 without any significant changes. The other problem here is inconsistency, I can call the method statically at the moment but I can't do it via a callback? Either the behaviour needs to match or revert it back to an E_STRICT message until PHP 6. Scott Marcus Boerger wrote:
Hello Scott, actually it was a bug. We, sorry I, did not spot this in earlier versions. Now saying you rely on a bug in PHP 5 to be able to execute PHP 4 code simply does not work. marcus Wednesday, January 30, 2008, 11:48:50 AM, you wrote:
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
Best regards, Marcus


« previous php.internals (#35030) next »