I would definitely not advocate to use [] in a type hint. For the same reason
you don't use array() but array :)
It'd be:
function typeHinted(array $array = []) {
...
}
I don't see any issue with that. I'm talking about the construct that allows
you to create an array.
Andi
> -----Original Message-----
> From: Hannes Magnusson [mailto:[EMAIL PROTECTED]
> Sent: Sunday, February 04, 2007 6:30 AM
> To: Andi Gutmans
> Cc: [email protected]
> Subject: Re: [PHP-DEV] Syntactic improvement to array
>
> Hi Andi
>
> function typeHinted([] $array = []) { // type hint array,
> default to empty one
> if(count($array)) {
> array_merge($array, ["foo" => []]); // merge $array
> with array("foo" => array());
> return $array;
> }
> return []; // empty array
> }
>
> typeHinted([1 => [1 => []]]); // array(1 => array(1 => array()));
>
> -1 from me
>
> -Hannes
>
> On 2/4/07, Andi Gutmans <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I thought I may have brought this up a long time ago but
> couldn't find anything in the archives.
> > For a long time already I've been thinking about possibly
> adding a new
> > syntax for array(...) which would be shorter. I'd suggest
> [...]. While
> > I am usually not in favor of having more than one way to do
> things, I think it'd look much more elegant especially (but
> not only) for nested arrays.
> >
> > So what I'm thinking of is:
> > array(1, 2, 3) == [1, 2, 3]
> > array(1, 2, array("foo", "bar")) == [1, 2, ["foo", "bar"]]
> array("key"
> > => 1, "key2" => 2) == ["key" => 1, "key2" => 2]
> >
> > $arr = [1, 2, 3]
> > vs.
> > $arr = array(1, 2, 3)
> >
> > Well enough examples given :)
> > I think it's not worth doing unless there's overwhelming support as
> > it's not desperately needed. But I'd be interested to hear
> people's thoughts. It seems implementation shouldn't be an
> issue but I'd have to dive a bit deeper.
> >
> > Andi
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List To
> unsubscribe,
> > visit: http://www.php.net/unsub.php
> >
> >
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php