#48948 [Opn->WFx]: Private/Protected method errors called via call_user_func_array are ambigious

From: Date: Mon, 20 Jul 2009 14:05:15 +0000
Subject: #48948 [Opn->WFx]: Private/Protected method errors called via call_user_func_array are ambigious
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2517@lists.php.net to get a copy of this message
ID: 48948 Updated by: felipe@php.net Reported By: bigdan at gmail dot com -Status: Open +Status: Wont fix Bug Type: Documentation problem Operating System: linux PHP Version: Irrelevant New Comment: It was improved in the 5.3+ version. We got that: Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method A::Foo() ... But it's not intended to be backported to 5.2.x. Thanks. Previous Comments: ------------------------------------------------------------------------ [2009-07-16 20:15:08] bigdan at gmail dot com Description: ------------ If you call an instantiated object's private/protected method's via call_user_func_array(array($objFoo, 'bar'), $arrParams) the error message regarding why the method is not callable is too generic. It implies the function does not exist. Please note: This is NOT a bug in the code, but rather a error message that could definitely be more helpful, which is why it's filed under documentation. Reproduce code: --------------- <?php class A { private function Foo() { return 'Foo!'; } } $objA = new A(); call_user_func_array(array($objA, 'Foo'), array()); ?> Expected result: ---------------- Fatal error: Call to private method A::Foo() from context '' in on line 10 Actual result: -------------- Warning: call_user_func_array(): First argument is expected to be a valid callback, 'A::Foo' was given in on line 10 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48948&edit=1

« previous php.doc.bugs (#2517) next »