Re: Concept: "arrayable" pseudo type and \Arrayable interface
| From: | Ben Ramsey | Date: | Sun, 17 Nov 2019 23:44:37 +0000 |
| Subject: | Re: Concept: "arrayable" pseudo type and \Arrayable interface | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107814@lists.php.net to get a copy of this message | ||
> On Nov 17, 2019, at 17:28, Mike Schinkel <mike@newclarity.net> 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 such that the objects can be used interchangeably with a
> built-in array
I completely agree. I would love to see anything implementing ArrayAccess able to be used in any of
the array functions.
This might be a way-out-in-left-field concept, but if we went down this path, perhaps a PHP array
could become an object internally (i.e., ArrayObject) without changing the way it works in existing
code? Then, if/when generics are introduced, a PHP array would already be a class to which a generic
type parameter could be applied.
-Ben