php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48948 Private/Protected method errors called via call_user_func_array are ambigious
Submitted: 2009-07-16 20:15 UTC Modified: 2009-07-20 14:05 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: bigdan at gmail dot com Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bigdan at gmail dot com
New email:
PHP Version: OS:

 

 [2009-07-16 20:15 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-20 14:05 UTC] felipe@php.net
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 13:01:28 2025 UTC