Bug #48019 [Com]: ReflectionMethod's invoke() and call_user_func() do not return by reference

From: Date: Wed, 12 Apr 2023 11:39:13 +0000
Subject: Bug #48019 [Com]: ReflectionMethod's invoke() and call_user_func() do not return by reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244182@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48019&edit=1

 ID:                 48019
 Comment by:         talknewsbusiness at gmail dot com
 Reported by:        pulni4kiya at abv dot bg
 Summary:            ReflectionMethod's invoke() and call_user_func() do
                     not return by reference
 Status:             Open
 Type:               Bug
 Package:            Reflection related
 Operating System:   *
 PHP Version:        5.2.9
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2018-07-08 19:47:23] cmb@php.net

Behavior confirmed: <https://3v4l.org/NJBRv>.  However,
note the
notice!

Anyhow, this is either a bug or a documentation problem.

------------------------------------------------------------------------
[2009-04-19 22:50:10] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=48019&edit=1


Thread (5 messages)

« previous php.bugs (#244182) next »