Re: [PHP-DEV] Proposal for a RFC

2019-08-28 Thread Marco Pivetta
Hey Benjamin, On Thu, Aug 29, 2019, 05:09 Benjamin Eberlei wrote: > > > On Sun, May 5, 2019 at 5:08 PM Nicolas Grekas > wrote: > >> Le sam. 4 mai 2019 à 18:37, Marco Pivetta a écrit : >> >> > Hi Steven, >> > >> > As it currently stands, the array cast is the only operation capable of >> > expo

Re: [PHP-DEV] Proposal for a RFC

2019-08-28 Thread Benjamin Eberlei
On Sun, May 5, 2019 at 5:08 PM Nicolas Grekas wrote: > Le sam. 4 mai 2019 à 18:37, Marco Pivetta a écrit : > > > Hi Steven, > > > > As it currently stands, the array cast is the only operation capable of > > exposing object state without triggering any kind of access guards: it is > > very much

Re: [PHP-DEV] Proposal for a RFC

2019-06-13 Thread Marco Pivetta
On Thu, Jun 13, 2019 at 4:23 PM Steven Wade wrote: > > I guess that's what it comes down to, what *specific* use cases would > this > > feature be intended to help with? Is there some code of your own that > > inspired you to propose it, or something you've seen publically that > would > > benefi

Re: [PHP-DEV] Proposal for a RFC

2019-06-13 Thread Steven Wade
Apologies for the super late response: > A recursive method would certainly have more value, because it actually > does something more than translate one syntax to another. On the other > hand, the use case that comes to mind is serialization, and we already have > more specific methods and system

Re: [PHP-DEV] Proposal for a RFC

2019-05-08 Thread Steven Wade
Hi Kalle, > On May 4, 2019, at 12:08 PM, Kalle Sommer Nielsen wrote: > > Hi > > Den lør. 4. maj 2019 kl. 17.58 skrev Steven Wade : >> >> Hi Internals team! >> >> I have an idea for a feature that I'd love to see in the language one day >> and wanted to run the idea by you all. >> >> The ide

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
Hi Marco, > The alternative is to expand the reflection API with an array cast operation > in there, and then migrate existing userland usages to that to retain BC. That's an interesting proposal - adding new reflection abilities. Hm.. > In addition to that, as someone that used to write a lot

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Marco Pivetta
Hey Steven, On Tue, 7 May 2019, 14:25 Steven Wade, wrote: > > I’m not against the proposal. I’m mainly asking if there are other ways > in the language today to accomplish similar things. I would prefer to see > interfaces used over more magic methods (something like ArraySerializable). > > A T

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
> On May 7, 2019, at 8:52 AM, Stephen Reay wrote: > > >> On 7 May 2019, at 19:47, Steven Wade wrote: >> >>> Maybe I’m missing the point (I’ve never used it) of VarDumper, but isn’t >>> this type of thing exactly why the `__debugInfo` magic method exists? >> >> >> I can't speak for the ex

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Stephen Reay
> On 7 May 2019, at 19:47, Steven Wade wrote: > >> Maybe I’m missing the point (I’ve never used it) of VarDumper, but isn’t >> this type of thing exactly why the `__debugInfo` magic method exists? > > > I can't speak for the exact reason a library like VarDumper is using casting > versus __

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
> Maybe I’m missing the point (I’ve never used it) of VarDumper, but isn’t this > type of thing exactly why the `__debugInfo` magic method exists? I can't speak for the exact reason a library like VarDumper is using casting versus __debugInfo, but in trying to find a substitute this morning, I

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Stephen Reay
> On 7 May 2019, at 19:22, Nikita Popov wrote: > > On Tue, May 7, 2019 at 2:20 PM Steven Wade wrote: > >>> I want to weight in with what Marco expressed. I have the very same >> concerns and they are major ones for many use cases. Mine is VarDumper. >>> >>> Please don't do this the way it is

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
> We can add a separate function to provide this functionality. We should do > that anyway because it's both clearer and because (array) already requires > some special handling for ArrayObject that could be avoided. Are you talking about adding a separate function to replace my proposed __toA

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
> I’m not against the proposal. I’m mainly asking if there are other ways in > the language today to accomplish similar things. I would prefer to see > interfaces used over more magic methods (something like ArraySerializable). A Twitter user pointed out that 7.4 is adding two new magic methods

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Nikita Popov
On Tue, May 7, 2019 at 2:20 PM Steven Wade wrote: > > I want to weight in with what Marco expressed. I have the very same > concerns and they are major ones for many use cases. Mine is VarDumper. > > > > Please don't do this the way it is described. > > > Is there a way that you'd suggest? First

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
> I want to weight in with what Marco expressed. I have the very same concerns > and they are major ones for many use cases. Mine is VarDumper. > > Please don't do this the way it is described. Is there a way that you'd suggest? First of all, TIL some cool things about "(array) $foo" and how V

Re: [PHP-DEV] Proposal for a RFC

2019-05-06 Thread Ben Ramsey
> On May 6, 2019, at 09:37, Steven Wade wrote: > > That being said, adding an interface like `ArraySerializable` might be nice > too. I'm seeing technical arguments against adding magic casts, but (just > spit-balling here), what if a class implemented a new `ArraySerializable` > interace with

Re: [PHP-DEV] Proposal for a RFC

2019-05-06 Thread Steven Wade
> On May 5, 2019, at 10:59 AM, Ben Ramsey wrote: > > >> On May 4, 2019, at 09:58, Steven Wade wrote: >> >> Hi Internals team! >> >> I have an idea for a feature that I'd love to see in the language one day >> and wanted to run the idea by you all. >> >> The idea is to add a new magic met

Re: [PHP-DEV] Proposal for a RFC

2019-05-05 Thread Nicolas Grekas
Le sam. 4 mai 2019 à 18:37, Marco Pivetta a écrit : > Hi Steven, > > As it currently stands, the array cast is the only operation capable of > exposing object state without triggering any kind of access guards: it is > very much required for anything that works with reflection and typed > propert

Re: [PHP-DEV] Proposal for a RFC

2019-05-05 Thread Ben Ramsey
> On May 4, 2019, at 09:58, Steven Wade wrote: > > Hi Internals team! > > I have an idea for a feature that I'd love to see in the language one day and > wanted to run the idea by you all. > > The idea is to add a new magic method "__toArray()" that would allow a > developer to specifiy ho

Re: [PHP-DEV] Proposal for a RFC

2019-05-04 Thread Marco Pivetta
Hi Steven, As it currently stands, the array cast is the only operation capable of exposing object state without triggering any kind of access guards: it is very much required for anything that works with reflection and typed properties, and possibly the only operation in PHP that operates on stat

Re: [PHP-DEV] Proposal for a RFC

2019-05-04 Thread Paul Jones
> On May 4, 2019, at 11:08, Kalle Sommer Nielsen wrote: > > Hi > > Den lør. 4. maj 2019 kl. 17.58 skrev Steven Wade : >> >> Hi Internals team! >> >> I have an idea for a feature that I'd love to see in the language one day >> and wanted to run the idea by you all. >> >> The idea is to add

Re: [PHP-DEV] Proposal for a RFC

2019-05-04 Thread Kalle Sommer Nielsen
Hi Den lør. 4. maj 2019 kl. 17.58 skrev Steven Wade : > > Hi Internals team! > > I have an idea for a feature that I'd love to see in the language one day and > wanted to run the idea by you all. > > The idea is to add a new magic method "__toArray()" that would allow a > developer to specifiy h

Re: [PHP-DEV] Proposal for a RFC

2019-05-04 Thread Kalle Sommer Nielsen
> I find it easy to imagine that objects not implementing __toArray() would > continue to exhibit that behavior. Obviously. So what about code that operates on this behavior, should that then suddenly break if the object implements an __toArray() method? That sounds wrong to me -- regards, Ka

Re: [PHP-DEV] Proposal for a RFC

2019-05-04 Thread Paul Jones
Hi Steven, > The idea is to add a new magic method "__toArray()" that would allow a > developer to specifiy how a class is cast to an array. The idea is the same > mentality of __toString(), but, for arrays. I'd like to see this as well. -- Paul M. Jones pmjo...@pmjones.io http://paul-m-jone

[PHP-DEV] Proposal for a RFC

2019-05-04 Thread Steven Wade
Hi Internals team! I have an idea for a feature that I'd love to see in the language one day and wanted to run the idea by you all. The idea is to add a new magic method "__toArray()" that would allow a developer to specifiy how a class is cast to an array. The idea is the same mentality of _