Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Replace old array() syntax with new [] #898

Closed
wants to merge 1 commit into from

Conversation

bocharsky-bw
Copy link
Contributor

We could use a new array syntax [] based on the fact that Symfony 3 require PHP >=5.5.9

@Pierstoval
Copy link
Contributor

I don't know, I like it like it is, I don't like the new syntax (reminds me of Javascript too much, and is a pain to write on Mac rather than the classic syntax).

@bocharsky-bw bocharsky-bw force-pushed the new-array-syntax branch 2 times, most recently from 84e96bb to e581428 Compare December 3, 2015 09:08
@calinpristavu
Copy link

It's true that the old syntax is "prettier", however IMO it's just a matter of habit.
PHPCS also sniffs it and throws a warning.
so I'm +1

@bocharsky-bw
Copy link
Contributor Author

@Pierstoval Why does it pain for you to write new array syntax on Mac?

Almost any application is written with PHP and JS, so to have the same syntax is more readable IMHO.

@Pierstoval
Copy link
Contributor

It's a matter of taste, I won't blame anyone for using it, but I personally don't like it because on mac I always confound { and [ (and reversely } and ] ) when I write code...

@Tobion
Copy link
Contributor

Tobion commented Dec 3, 2015

We don't use the new sytax in symfony/symfony just to ease merging. But we can easily use it in symfony-standard. 👍

@gnugat
Copy link

gnugat commented Dec 3, 2015

@calinpristavu

PHPCS also sniffs it and throws a warning.

But there's no reason to throw a warning: the "old" syntax hasn't been deprecated or anything. The only issue would be mixing both syntaxes.

@bocharsky-bw

Almost any application is written with PHP and JS

Symfony can be used as a full stack framework with PHP and javascript mixed, but that's not the only usage. It can also be used to create APIs where you wouldn't have any javascript. It could be used in many ways where you wouldn't have javascript. Also there's no way to know which usage is the most prevalent.

@Pierstoval

It's a matter of taste

I agree. It doesn't matter which one we use as long as we're consistent everywhere.

@bocharsky-bw
Copy link
Contributor Author

I agree. It doesn't matter which one we use as long as we're consistent everywhere.

@gnugat It means that I need to use old syntax in my project if I want to be consistent with Symfony SE for now. But why I should do it? The main benefit of new array syntax is that it's shorter than old syntax. So why don't use it if we can.

/**
* @var ClassLoader $loader
/*
* @var ClassLoader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes should be reverted to actually work in IDEs. fabbot.io is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, reverted.

We could use new array syntax based on the fact that Symfony 3 require PHP >=5.5.9
@Pierstoval
Copy link
Contributor

@gnugat It means that I need to use old syntax in my project if I want to be consistent with Symfony SE for now. But why I should do it? The main benefit of new array syntax is that it's shorter than old syntax. So why don't use it if we can.

It's all about standards. Php-fig and PSRs were created in order to simplify writing "beautiful" (rather than "good") PHP applications, and having standards for coding is better to avoid one developer to use tabs instead of spaces, or a developer wanting to put opening brackets in the same line as the declaration, or in the following line.

For 20 years (exaggerating ? :p ) we wrote array(), so everyone know this syntax, this why it's "standard". The short-syntax was implemented in 5.4 and many users don't even know about traits...

@xabbuh
Copy link
Member

xabbuh commented Dec 4, 2015

I don't care about this as it dos not really matter whether or not we use the short syntax (people could also change these few occurrences on their own if they feel disturbed by it).

@fabpot
Copy link
Member

fabpot commented Dec 18, 2015

Thank you @bocharsky-bw.

fabpot added a commit that referenced this pull request Dec 18, 2015
This PR was submitted for the master branch but it was merged into the 3.0 branch instead (closes #898).

Discussion
----------

Replace old array() syntax with new []

We could use a new array syntax `[]` based on the fact that Symfony 3 require PHP `>=5.5.9`

Commits
-------

f5b1ae8 Replace old array() syntax with new []
@fabpot fabpot closed this Dec 18, 2015
@bocharsky-bw bocharsky-bw deleted the new-array-syntax branch December 18, 2015 17:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants