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

2019-11-17 Thread Mike Schinkel
> On Nov 17, 2019, at 6:51 PM, Rowan Tommins wrote: > > I'm not sure avoiding the name "toArray" necessarily leads to "really long > method names" - even with extremely specific distinctions, you don't need to > call the method "toJsonArrayForVersion5OfTheApi", just "toV5Json" or >

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

2019-11-17 Thread Rowan Tommins
On 17/11/2019 23:01, Mike Schinkel wrote: Consider this: __toArray() is hardly a rare case where a short name can be applied in multiple contexts.  We have infinite contexts where we need to name methods for one context that might conflict with others, and so I have been

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

2019-11-17 Thread Ben Ramsey
> On Nov 17, 2019, at 17:28, Mike Schinkel wrote: > > If we are going to open up arrays for enhancement in PHP 8 I would ask that > we seriously consider addressing the various differences between a built-in > array and an instance of ArrayObject and/or the related associated interfaces >

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

2019-11-17 Thread Mike Schinkel
> On Nov 17, 2019, at 9:41 AM, Aimeos | Norbert Sendetzky > wrote: > > Since PHP 7.1 there's the "iterable" pseudo type hint that matches > "array" and "Traversable". > > PHP frameworks would profit from support of an "arrayable" pseudo type > hint that matches "array" and all objects that

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

2019-11-17 Thread Mike Schinkel
> On Nov 17, 2019, at 2:27 PM, Rowan Tommins wrote: > Well, pretty much any method that returns array *could* be called "to array", > but not many would be good candidates for such a generic name. You might > return an array structure to be incorporated into a JSON response, or to be > passed

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

2019-11-17 Thread Rowan Tommins
[Note: I've included the full text of the previous message as it wasn't sent to the list.] On 17/11/2019 18:35, Aimeos | Norbert Sendetzky wrote: It feels like there are two alternative suggestions here. Not only do they use the same keyword to mean different things, but "convertible to

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

2019-11-17 Thread Rowan Tommins
On 17/11/2019 14:41, Aimeos | Norbert Sendetzky wrote: PHP frameworks would profit from support of an "arrayable" pseudo type hint that matches "array" and all objects that implements "Traversable", "ArrayAccess" and "Countable". ... It would be useful to implement an Arrayable interface

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

2019-11-17 Thread Aimeos | Norbert Sendetzky
>>> And if necessary, we can convert them to native arrays: >>> >>> if( $arrayable instanceof \Arrayable ) { >>>$arrayable = $arrayable->toArray(); >>> } >> >> Also the toArray() should be called when an Arrayable is cast to an array: >> (array)$arrayable. >> >> And shouldn’t the toArray match

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,

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

2019-11-17 Thread Ken Stanley
On Sun, Nov 17, 2019 at 9:42 AM Aimeos | Norbert Sendetzky < norb...@aimeos.com> wrote: > Since PHP 7.1 there's the "iterable" pseudo type hint that matches > "array" and "Traversable". > > PHP frameworks would profit from support of an "arrayable" pseudo type > hint that matches "array" and all

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

2019-11-17 Thread Aimeos | Norbert Sendetzky
Since PHP 7.1 there's the "iterable" pseudo type hint that matches "array" and "Traversable". PHP frameworks would profit from support of an "arrayable" pseudo type hint that matches "array" and all objects that implements "Traversable", "ArrayAccess" and "Countable". Thus, we could pass arrays