Req #25069 [Com]: methods called w call_user_func have no $this

From: Date: Wed, 01 Sep 2021 18:53:16 +0000
Subject: Req #25069 [Com]: methods called w call_user_func have no $this
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236343@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25069&edit=1 ID: 25069 Comment by: lildurk25069 at gmail dot com Reported by: tater at potatoe dot com Summary: methods called w call_user_func have no $this Status: Closed Type: Feature/Change Request Package: Feature/Change Request Operating System: * PHP Version: 5CVS-2003-11-29 (dev) Block user comment: N Private report: N New Comment: Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults aged 19 and older. We’re an exclusively online retailer and wholesaler for recreational cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe our work is meaningful and we take pride in our mandate to promote the socially responsible use of legal cannabis. https://lildurk.com/ Previous Comments: ------------------------------------------------------------------------ [2004-10-13 09:21:09] derick@php.net This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2004-10-13 02:19:17] php at bobsilva dot com This is fixed in 5.1 CVS ------------------------------------------------------------------------ [2003-08-13 04:04:07] tater at potatoe dot com Description: ------------ If you call an object's method, $x->foo(), and then call parent:;bar() (or self:;bar() or xyz::abc()), $this will be defined inside bar() and point to the original object ($x). But if you use call_user_func() or call_user_func_array(), $this is not defined. Reproduce code: --------------- class foo { function a() { if (isset($this)) var_dump($this); else print "\$this not defined.\n"; } function b() { self::a(); call_user_func(array('self','a')); } } $x = new foo; $x->b(); Expected result: ---------------- object(foo)#1 (0) { } object(foo)#1 (0) { } Actual result: -------------- object(foo)#1 (0) { } $this not defined. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=25069&edit=1

« previous php.bugs (#236343) next »