Bug #77877 [Opn->Asn]: call_user_func() passes $this to satatic methods

From: Date: Thu, 11 Apr 2019 10:34:28 +0000
Subject: Bug #77877 [Opn->Asn]: call_user_func() passes $this to satatic methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220399@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77877&edit=1 ID: 77877 Updated by: dmitry@php.net Reported by: dmitry@php.net Summary: call_user_func() passes $this to satatic methods -Status: Open +Status: Assigned Type: Bug Package: Scripting Engine problem Operating System: * PHP Version: 7.1Git-2019-04-11 (Git) -Assigned To: +Assigned To: dmitry Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2019-04-11 10:34:15] dmitry@php.net 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) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77877&edit=1

« previous php.bugs (#220399) next »