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
 [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

Pull Requests

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
 [2023-04-12 11:39 UTC] talknewsbusiness at gmail dot com
Business Talk News are sharing latest news about business, law, finance, tax, banking, loans, trading, share market etc. More info to visit: (https://businesstalknews.com)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 10:01:28 2024 UTC