|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48019 ReflectionMethod's invoke() and call_user_func() do not return by reference
Submitted: 2009-04-19 22:50 UTC Modified: 2018-07-08 19:47 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: pulni4kiya at abv dot bg Assigned:
Status: Open Package: Reflection related
PHP Version: 5.2.9 OS: *
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: pulni4kiya at abv dot bg
New email:
PHP Version: OS:


 [2009-04-19 22:50 UTC] pulni4kiya at abv dot bg
The problem is that ReflectionMethod's invoke() method does not return reference (when it should)! Neither does call_user_func() for that matter.

Reproduce code:
class A {
	public static $c = 100;
	public static function &D() {
		return self::$c;

echo A::$c; //prints 100
$cRef1 =& A::D();
$cRef1 = 200;
echo A::$c; //prints 200
$a = new ReflectionClass('A');
$d = $a->getMethod('D');
$cRef2 =& $d->invoke(null); //DOES NOT RETURN REFERENCE!!!
$cRef2 = 300;
echo A::$c; //prints 200

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-02 02:38 UTC]
-Package: Feature/Change Request +Package: Reflection related
 [2018-07-08 19:47 UTC]
Behavior confirmed: <>.  However, note the

Anyhow, this is either a bug or a documentation problem.
 [2018-07-08 19:47 UTC]
-Type: Feature/Change Request +Type: Bug
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Aug 19 08:04:05 2022 UTC