ID: 40398 Updated by: [EMAIL PROTECTED] Reported By: levi at alliancesoftware dot com dot au -Status: Open +Status: Bogus Bug Type: Scripting Engine problem PHP Version: 5CVS-2007-02-08 (CVS) New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Use: call_user_func_array(array($this, 'parent::__construct'), $args); Previous Comments: ------------------------------------------------------------------------ [2007-02-08 05:28:10] levi at alliancesoftware dot com dot au Description: ------------ parent::func() uses a static function call syntax but is 'special' in that you are allowed to use it to call nonstatic functions without generating any warnings. Callbacks with E_STRICT on don't recognise the 'special' nature of 'parent' and 'self'. (happens with call_user_func(), call_user_func_array(), array_map() etc) This means that it is impossible to call a parent method through a callback without generating a warning. Therefore, code such as: public function __construct(/* variable argument list */) { $args = func_get_args(); call_user_func_array('parent', '__construct), $args); /* ... extra initialisation here ... */ } will not work with E_STRICT Note: Related to #36011, but not quite the same (this one involves inheritance) Reproduce code: --------------- #!/usr/local/src/php5/php-5.2.CVS-cgi/sapi/cgi/php -q <? error_reporting(E_ALL | E_STRICT); class Ancestor { public function f($a) { echo $a; } } class Descendant extends Ancestor { public function f($a) { } public function g($a) { // This is fine parent::f($a); // This gives a warning call_user_func(array('parent', 'f'), $a); // This is fine self::f($a); // This gives a warning call_user_func(array('self', 'f'), $a); // This is fine Descendant::f(4); // This gives a warning [probably not avoidable] call_user_func(array('Descendant', 'f'), $a); } } $x = new Descendant(); $x->g(3); ?> Expected result: ---------------- 33 Actual result: -------------- PHP Strict Standards: Non-static method [...] cannot be called statically, assuming $this from compatible context Descendent in /home/levi/public_html/test2.php5 on line [...] (See code for which lines generate the warning) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40398&edit=1