|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-04-11 10:34 UTC] dmitry@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: dmitry
[2019-04-11 10:53 UTC] daverandom@php.net
-Summary: call_user_func() passes $this to satatic methods
+Summary: call_user_func() passes $this to static methods
[2019-04-11 11:31 UTC] dmitry@php.net
[2019-04-11 11:31 UTC] dmitry@php.net
-Status: Assigned
+Status: Closed
[2019-04-11 11:32 UTC] me at mega6382 dot me
[2019-04-11 18:23 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 21:00:01 2025 UTC |
Description: ------------ call_user_func([$obj,"static_method"]) actually performs non-static call. Most other internal functions that use callbacks (e.g. array_map) are not affected. Test script: --------------- <?php class Foo { static public function bar() { var_dump($this); } } try { array_map([new Foo, 'bar'],[1]); } catch (Throwable $e) { echo $e->getMessage() . "\n"; } try { call_user_func([new Foo, 'bar']); } catch (Throwable $e) { echo $e->getMessage() . "\n"; } ?> Expected result: ---------------- Using $this when not in object context Using $this when not in object context Actual result: -------------- Using $this when not in object context object(Foo)#3 (0) { }