Hi,
No one said it's a matter of life and death. But is it only a matter of life
and death improvements that should be considered for PHP?
The typical use case that benefits most from this is when a function accepts
arrays as a means of structured/named/nested options, something I use a lot.
Compare verbosity and readability:
quoteInto('SELECT * FROM Table WHERE x > ? and y < ?', array(10, 50));
vs:
quoteInto('SELECT * FROM Table WHERE x > ? and y < ?', [10, 50]);
renderSomething(array('exclude' => array('a', 'b', 'c'), 'include' =>
array('d', 'e', 'f')));
vs:
renderSomething(['exclude' => ['a', 'b', 'c'], 'include' => ['d', 'e',
'f']]);
or even vs:
renderSomething(['exclude' : ['a', 'b', 'c'], 'include' : ['d', 'e', 'f']]);
The key thing is, no one is requesting that array() be removed. Just that an
obvious and commonly used shortcut is added. It's not confusing, it's not
hard, JavaScript also has BOTH short and long syntax for arrays and objects:
var array = new Array(); -- same as -- var array = [];
var object = new Object(); -- same as -- var object = {};
And when people have both of those, guess which one they use in more than
90% of the cases.
Regards,
Stan Vassilev
Hello,
As I always will say -1 to this.
But I have a question, people here talk that this is very very useful in
some cases. Can you please show others such cases so we can get your
point?
I really want to know this super hyper cases, this syntax is mega useful.
Regards, Dimitar
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php