|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-01-02 11:25 UTC] nikic@php.net
-Status: Open
+Status: Verified
-PHP Version: 7.3.0
+PHP Version: All
[2019-01-02 11:25 UTC] nikic@php.net
[2021-09-02 13:27 UTC] nikic@php.net
[2021-09-02 13:27 UTC] nikic@php.net
-Status: Verified
+Status: Assigned
-Assigned To:
+Assigned To: nikic
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
Description: ------------ When calling dynamically a static method, with array('static', 'method'), from the right class context, PHP emits an error 'Class 'static' not found'. Using call_user_func($method); with the same array, leads to the correct call to the method. The same problem applies to 'self' and 'parent'. https://3v4l.org/VKFaQ https://3v4l.org/0eacu https://3v4l.org/HkFmd Test script: --------------- <?php class x { static function a() { // display the current class echo __METHOD__; } static function b($method) { // display the current class with method a above call_user_func($method); // This stops with a Fatal Error $method(); } } (new x)->b(array('static', 'a')); ?> Expected result: ---------------- x::a x::a Actual result: -------------- x::a Fatal error: Uncaught Error: Class 'static' not found