|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-02-18 09:53 UTC] mblarsen at gmail dot com
Description: ------------ If you pass a string-variable to a method that accepts the variable by reference, then the same variable in the calling context no longer behaves like a normal string when it comes to invoking callables on `self::` (and like other contexts) but instead produces the error: Function name must be a string, despite the variable is a valid string. The test script below show different cases. Notably is the last case where the value of the "damaged" variable is passed to a new variable to achieve the desired result with success, thus the content is fine, but the variable is "damaged". Test script: --------------- http://sandbox.onlinephpfunctions.com/code/5fa7c924f4e8514d6020b180decd96e5969d4014 In the linked sandbox you can see that it works in 5.6.x but not in either of the released 7 versions: 7.0.3, 7.0.1, etc. Expected result: ---------------- Test scripts shows the bug under difference circumstances. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Reproduce case for posterity: function getMethodName(&$methodName) { $methodName = Abc::METHOD_NAME; } class Abc { const METHOD_NAME = "goal"; private static function goal() { echo "success", PHP_EOL; } public static function run() { $method = "foobar"; getMethodName($method); printf( "isCallable(self::%s) is %d\n", $method, is_callable("self::$method") ); self::$method(); } } Abc::run();