Re: [PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Steven Wade
> I think the motivation is exactly what you said. Allowing developers more > control over how the object is treated when casted to an array - which would > include when it is passed into an array_* function. I couldn’t (and didn’t) have said it better myself. My motivation is really just to gi

Re: [PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Steven Wade
> Sorry if it's been said in the discussion so far, but I do not see why > `print_r` should convert anything to an array. It accepts multiple > kinds of types including strings, numbers, and so on, and I think > adding this behavior to `print_r` is a different thing than wanting a > standard way

Re: [PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Steven Wade
>> 3. The weak point of this proposal is the by reference handling for sort et >> al. Counterpoint: if you pass a variable to preg_match, then matches gets >> converted from anything to array, so i believe by reference casting should >> change the original value (https://3v4l.org/XUJ5m

Re: [PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Steven Wade
> I am open to the idea of having __toArray. I just have a few questions about > the RFC details. > > 1. print_r($object) would somehow call __toArray you say. Why would it cause > a cast when nothing else is cast? I would prefer print_r((array) $person); Originally I intended the proposal to

Re: [PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Steven Wade
> `__toArray` as a magic function call when `(array)` cast happen is a bad > idea: it is a BC break, Adding a new magic method is not a backwards compatibility break. The PHP documentation on magic methods states: "Caution PHP reserves all function names starting with __ as magical. It is re

Re: [PHP-DEV] What about a magic __toArray() method?

2020-02-04 Thread Steven Wade
> Oh there is even a rfc. https://wiki.php.net/rfc/to-array What is the > status of this? This RFC has now been moved to “under discussion” with the discussion happening here: https://externals.io/message/108369

[PHP-DEV] [RFC - discussion] __toArray()

2020-02-04 Thread Steven Wade
d now is the best time. https://wiki.php.net/rfc/to-array <https://wiki.php.net/rfc/to-array> Cheers, Steven Wade

Re: [PHP-DEV] What about a magic __toArray() method?

2020-02-04 Thread Steven Wade
> Oh there is even a rfc. https://wiki.php.net/rfc/to-array What is the > status of this? Hi there, I’m the author of that RFC. I intend to post it officially for discussion soon, I’ve just been busy and haven’t had the time that would be needed to respond to the discussion emails when they came

Re: [PHP-DEV] Concept: "arrayable" pseudo type and \Arrayable interface

2019-11-17 Thread Steven Wade
I proposed a while back adding a new magic method __toArray that would automatically cast. I'm halfway through writing the RFC (in draft and unpublished). I wonder how that could tie in to this proposal. Or even be a precursor to this. Sent from my iPhone > On Nov 17, 2019, at 11:10 AM, Ken

[PHP-DEV] Re: Request for RFC karma

2019-08-27 Thread Steven Wade
Thanks! > On Aug 27, 2019, at 1:00 PM, Christoph M. Becker wrote: > > On 27.08.2019 at 18:50, Steven Wade wrote: > >> Hi all, I'd like to move forward with my proposed `__toArray()` RFC >> <https://marc.info/?l=php-internals&m=155698189420252&w=2

[PHP-DEV] Request for RFC karma

2019-08-27 Thread Steven Wade
Hi all, I'd like to move forward with my proposed `__toArray()` RFC <https://marc.info/?l=php-internals&m=155698189420252&w=2> and see how it fares. Could someone grant RFC karma to my stevenwadejr account? Thank you, -- Steven Wade stevenwad...@gmail.com

Re: [PHP-DEV] Proposal for a RFC

2019-06-13 Thread Steven Wade
l that they can use when they see fit. Not everyone will use it and not everyone will see the benefit of it, and that's ok, but for those that would and could, __toArray() is for them (and me). -- Steven Wade stevenwad...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Add get_mangled_object_properties()

2019-05-14 Thread Steven Wade
sed on the odd behavior that current array casting exhibits and possibly losing that. By introducing this new function, it can be a more appropriate method of gaining insight into a class' properties. I like the idea of renaming the function to "get_mangled_object_vars()" that was m

Re: [PHP-DEV] Re: Proposal for a RFC

2019-05-13 Thread Steven Wade
posal and expand upon this question? If PHP were to have a __toArray() method, would you see it as being recursive? In your opinion, how should/would it react? I know not everyone will want or use this feature, but for those who would, it'd be a great addition IMO. So my goal of this initial thread was to see, "what if we had this feature, what would we want it to do?", and go from there. -- Steven Wade stevenwad...@gmail.com

Re: [PHP-DEV] Re: Proposal for a RFC

2019-05-13 Thread Steven Wade
add an optional helper for developers to simply converting their objects to arrays, and doing so with magic methods isn't without precedence and is more in line with PHP. -- Steven Wade stevenwad...@gmail.com

[PHP-DEV] Re: Proposal for a RFC

2019-05-13 Thread Steven Wade
> On May 4, 2019, at 10:58 AM, 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

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 >>

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
when writing/reading. But I'm not opposed to further discussing possible solutions. If this gets to the RFC stage, I'd prefer it be the best option for the language and most likely to pass. -- Steven Wade stevenwad...@gmail.com

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 e

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
n overwrite __debugInfo and cause unintended effects. I assume that's the reason for not using __debugInfo. -- Steven Wade stevenwad...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
ce my proposed __toArray() and casting functionality? Or did you mean adding a separate function to add functionality and insight into objects that packages like VarDumper have been using casting to access? -- Steven Wade stevenwad...@gmail.com -- PHP Internals - PHP Runtime Development M

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
urrent functionality. -- Steven Wade stevenwad...@gmail.com

Re: [PHP-DEV] Proposal for a RFC

2019-05-07 Thread Steven Wade
ng syntax? I'd like to find a way to not distrupt too much of what's out there, while also adding value to the end user. -- Steven Wade stevenwad...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

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

[PHP-DEV] Proposal for a RFC

2019-05-04 Thread Steven Wade
ile chatting a few months back, knocked out a proof-of-concept implementation <https://github.com/sgolemon/php-src/tree/experimental.toarray>. There's still work to be done if this proposal gets to the RFC phase, but again, just gauging interest here. I appreciate any feedback you all can provide. Thanks, - Steven Wade