|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-07-28 17:30 UTC] doctorrock83 at gmail dot com
Description:
------------
call_user_func_array() seems to modifies the internal object context while used with set_error_handler();
See the reproduce code.
Note: In the reproduce code, when not using call_user_func_array() (direct function call), there is no problem and the expected behavior occurs.
Reproduce code:
---------------
<?php
class Foo
{
public function call()
{
set_error_handler(array($this, '_errors'));
$result = call_user_func_array('ucfirst', array());
}
protected function _errors($errno, $errstr)
{
throw new Exception($errstr);
}
}
$f = new Foo;
$f->call();
Expected result:
----------------
Exception thrown with the message telling that ucfirst accept one parameter, none given
Actual result:
--------------
Fatal error: Call to protected method Foo::_errors() from context '' in /path/to/script.php on line XXX
PHP 5.3.0 returns :
Warning: Invalid callback Foo::_errors, cannot access protected method Foo::_errors() in /path/to/script.php on line XXX
Warning: ucfirst() expects exactly 1 parameter, 0 given in /path/to/script.php on line XXX
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 23 03:00:01 2025 UTC |
How do you then explain that just replacing $result = call_user_func_array('ucfirst', array()); by ucfirst(); makes PHP go into the custom error handler function ?)