Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-24 Thread Rowan Tommins
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

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-24 Thread Clint Priest
On 1/19/2023 12:40 PM, Marco Pivetta wrote: Not just that, but `debug_backtrace()` already exists for that purpose. I have use debug_backtrace() exactly for this purpose in the past. It was to make a protected property readable/writable, but only by certain "friend classes." It's pretty

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-24 Thread Dan Ackroyd
On Mon, 23 Jan 2023 at 16:27, Nicolas Grekas wrote: > > Legit concerns. I'm going to prepare a more extensive use case so the > motivations of RFC become more obvious. > > I'll get back on this thread when ready. Stay tuned :) Please can you look at implementing it as a function, that returns a

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-23 Thread Nicolas Grekas
> On 1/19/23 18:43, Ilija Tovilo wrote: > > You're right, we'll try to improve the wording and provide a handful of > > examples. Essentially, $callingScope should contain the class name of > > the calling scope, so the place where the magic method was called. When > > the calling scope is not a

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Tim Düsterhus
Hi On 1/19/23 18:43, Ilija Tovilo wrote: You're right, we'll try to improve the wording and provide a handful of examples. Essentially, $callingScope should contain the class name of the calling scope, so the place where the magic method was called. When the calling scope is not a class (global

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Marco Pivetta
Hey Ilija! On Thu, 19 Jan 2023, 20:26 Ilija Tovilo, wrote: > However, as demonstrated by the 3v4l, it's not > exactly trivial. It also requires the full stack trace, as well as all > frame objects and arguments. That's not going to be great for > performance. So saying debug_backtrace() exists

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Ilija Tovilo
Hi Aleksander >> https://wiki.php.net/rfc/pass_scope_to_magic_accessors > > Why not a new function, e.g. func_call_scope()? It could work > everywhere, not only in magic methods. > > I guess it would be tricky with calls to the parent magic method when > you need the "outer calling scope",

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Marco Pivetta
Not just that, but `debug_backtrace()` already exists for that purpose. On Thu, 19 Jan 2023, 19:23 Aleksander Machniak, wrote: > On 19.01.2023 17:23, Nicolas Grekas wrote: > > Hi internals, > > > > Ilija and I would like to start a discussion about the following RFC: > >

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Aleksander Machniak
On 19.01.2023 17:23, Nicolas Grekas wrote: Hi internals, Ilija and I would like to start a discussion about the following RFC: https://wiki.php.net/rfc/pass_scope_to_magic_accessors When using magic methods to access actual properties, respecting their declared visibility is often desired.

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Ilija Tovilo
Hi Tim >> Ilija and I would like to start a discussion about the following RFC: >> https://wiki.php.net/rfc/pass_scope_to_magic_accessors > > Unless I missed anything, the RFC does not explain how the values that > are passed into the second parameter will look like. What kinds of > strings

Re: [PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Tim Düsterhus
Hi On 1/19/23 17:23, Nicolas Grekas wrote: Ilija and I would like to start a discussion about the following RFC: https://wiki.php.net/rfc/pass_scope_to_magic_accessors When using magic methods to access actual properties, respecting their declared visibility is often desired. Yet, accessing

[PHP-DEV] [RFC] Pass Scope to Magic Accessors

2023-01-19 Thread Nicolas Grekas
Hi internals, Ilija and I would like to start a discussion about the following RFC: https://wiki.php.net/rfc/pass_scope_to_magic_accessors When using magic methods to access actual properties, respecting their declared visibility is often desired. Yet, accessing the calling scope to emulate the