Re: [RFC] Pass Scope to Magic Accessors

From: Date: Tue, 24 Jan 2023 21:29:39 +0000
Subject: Re: [RFC] Pass Scope to Magic Accessors
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-119422@lists.php.net to get a copy of this message
On 19/01/2023 19:25, Ilija Tovilo wrote:
This has been suggested before and we're consider it. Here's a comparable PHP implementation. https://3v4l.org/6Ua8t
I'm confused what all the complexity here is doing. I get the same result for that example with this one liner, using a tightly limited backtrace with no objects: function get_calling_scope() {
    return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['class'] ?? null;
} https://3v4l.org/VQARq3 In the RFC and this thread you talk a lot about parent::__get() needing special cases, but I don't understand why. In my mind, parent::__get('name') is just a regular method call, so why does it change the meaning of "calling scope"? Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#119422) next »