Symfony documentation boasts a tremendous reach among PHP community. That's why our actions and decisions can produce an immense positive effect. Considering all this, I'd like to propose the use of the PHP's short syntax array in the Symfony Documentation starting from 2.6 version.
Some context information:
Pros:
['bar', 'foo'] is much more beautiful than array('bar', 'foo').Cons:
To be honest, I can see only cons:
[] is not verbose and not as easy to understand as array(). It at least requires a minimum knowledge about newer PHP versions.[] in the code examples means we are not 100% friendly for them. On the other side, >PHP5.3 still supports the array() syntax, using array() doesn't reduce PHP5.3+ friendlyness.@WouterJ thanks for your comments. I'd like to clarify two things that you mentioned:
PHP core still supports 5.3 and I believe we should always follow the core in the documentation.
That's wrong. PHP 5.3 is completely deprecated. It doesn't receive ANY update, not even security updates. Total and completely deprecated.
It at least requires a minimum knowledge about newer PHP versions.
That's wrong. The short array syntax was released in 2012 and PHP 5.4 is not only "the future of PHP" but its past. PHP 5.4 is also deprecated since September 2014 (although it will still receive security updates for a year).
That's wrong. PHP 5.3 is completely deprecated. It doesn't receive ANY update, not even security updates. Total and completely deprecated
Sorry for the confusion, I meant Symfony core.
If Sf still supports outdated version (with all debate that can be, and I'm personally against support of deprecating things when there are potential security problem), it does not force the documentation to be outdated.
In facts using [] in the documentation can make people realize that their php version is deprecated. If they know, it will encourage theme to upgrage.
I think this is a very very good idea ! :+1:
it does not force the documentation to be outdated.
Using array() is as valid PHP5.6 as [] is. Using array() doesn't make your code/documentation outdated.
Of course this is totally valid (I didn't said the documentation will be deprecated ^^), but the good practice tends to be brackets usage. Not using it make the doc a bit "oldschool".
But anyway this is not the main point here.
Closing this issue because opinions are very divided. We'll reconsider this issue when 3.0 is released and some of its code starts using the short array syntax.
@javiereguiluz It's released now. I think short syntax arrays are better.
@JHGitty that's true ... but the decision won't change for now. Symfony won't use the short syntax neither for its code nor for its documentation.
Okay .. :( Thanks for your fast reply!
@JHGitty we have to support Symfony 2.8 for the next 3 years, merging its codebase with the 3.0 one each week. We don't want to handle conflicts between these branches all the time just because of a syntax change for arrays. This is why we made the decision to avoid using it (but your own code can of course the short array syntax)
Most helpful comment
@JHGitty we have to support Symfony 2.8 for the next 3 years, merging its codebase with the 3.0 one each week. We don't want to handle conflicts between these branches all the time just because of a syntax change for arrays. This is why we made the decision to avoid using it (but your own code can of course the short array syntax)