When I wrote the Assertion Inspector in Drupal 8 much of the library was
concerned with insuring that all members of an array where of type X, so
having a language construct to enforce this would be useful.  I'm no
language architect, but I'll take a crack at it..  We already have this

function foo ( array $myArray )

Can the parser deal with multiple hints like so?

function foo ( array string $myArray )

If so I think that's the most intuitive way of handling it.  If not maybe a
colon?

function foo ( array:string )

Or bracing as some docblocks already do

function foo (array[string] $myArray)

Having typed them out I sorta like the third one since it would allow
multiple types with the pipe operator as seen in another rfc

function foo (array[string | int] $myArray)



On Mon, Jan 30, 2017 at 3:18 PM, Rasmus Schultz <ras...@mindplay.dk> wrote:

> > Basically Foo[] to indicate an array of objects of type Foo
>
> I would be fine with that, as long as it's sugar for array<Foo>
>
>
> On Sun, Jan 29, 2017 at 4:51 PM, Sebastian Bergmann <sebast...@php.net>
> wrote:
>
> > Am 28.01.2017 um 17:10 schrieb Niklas Keller:
> > > sounds like everything you want is typed arrays?
> >
> > I would love typed arrays. Basically Foo[] to indicate an array of
> objects
> > of type Foo. IDEs such as PhpStorm as well as documentation tools already
> > support this syntax when used in docblocks.
> >
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

Reply via email to