php.net |  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
Votes:3
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-04-19 22:50 UTC] pulni4kiya at abv dot bg
Description:
------------
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:
----------------
100200300

Actual result:
--------------
100200200

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-02 02:38 UTC] jani@php.net
-Package: Feature/Change Request +Package: Reflection related
 [2018-07-08 19:47 UTC] cmb@php.net
Behavior confirmed: <https://3v4l.org/NJBRv>.  However, note the
notice!

Anyhow, this is either a bug or a documentation problem.
 [2018-07-08 19:47 UTC] cmb@php.net
-Type: Feature/Change Request +Type: Bug
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 22 13:01:29 2019 UTC