Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Remove invalid comma from php code example#8319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Remove invalid comma from php code example because it causes a php syntax error
xabbuh commentedAug 30, 2017
In fact, there is no problem in even terminating the last element in an array with a comma (and it's the code style used in Symfony). Are you sure that the syntax error was caused by this code? |
PhilETaylor commentedAug 30, 2017
@xabbuh While you are correct that there is no problem in terminating the last element in an array with a comma, this is not the case here. The comma is in the wrong place for it to be in the array. See that it is following a curly brace |
javiereguiluz commentedAug 30, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@PhilETaylor the problem is that this example is a bit complex and the comma looks wrong and out of place ... but I think it's technically correct. If we remove the entire function contents, it looks like this: publicfunctionconfigureOptions(OptionsResolver$resolver){$resolver->setDefaults(array('validation_groups' =>function (FormInterface$form) {... }, ));} In any case, maybe here we shouldn't add the trailing comma. We generally do that, but we don't always do that. For example, some examples in this page:https://github.com/symfony/symfony-docs/blob/master/service_container.rst contain arrays but they don't include the trailing comma. In short: even if the current example is technically correct, maybe removing the trailing comma makes it easier to understand it. |
PhilETaylor commentedAug 30, 2017
indeed you are right, now that I put the code in my ide it's a lot clearer and the PHP syntax is correct, still, best to remove it by merging this anyway like you said :) |
wouterj commentedAug 30, 2017
I would rather update the other examples to include the trailing comma. We decided that we follow the Symfony Coding Guidelines a couple years ago. Adding the trailing comma for array items is one of the rules in there. So a 👎 from me. (but this of course doesn't mean I hate your PR, thanks for taking the time to improve the docs!) |
HeahDude commentedAug 31, 2017
Closing as we all agree here that should not be changed. Thanks@rouenollivier for trying to improve the docs :). |
Remove invalid comma from php code example because it causes a php syntax error