Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
rouenollivier wants to merge1 commit intosymfony:3.3fromrouenollivier:patch-1
Closed

Remove invalid comma from php code example#8319

rouenollivier wants to merge1 commit intosymfony:3.3fromrouenollivier:patch-1

Conversation

@rouenollivier
Copy link

Remove invalid comma from php code example because it causes a php syntax error

Remove invalid comma from php code example because it causes a php syntax error
@xabbuh
Copy link
Member

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
Copy link
Contributor

@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} and not a bracket)

@javiereguiluz
Copy link
Member

javiereguiluz commentedAug 30, 2017
edited
Loading

@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
Copy link
Contributor

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
Copy link
Member

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
Copy link
Contributor

Closing as we all agree here that should not be changed. Thanks@rouenollivier for trying to improve the docs :).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@rouenollivier@xabbuh@PhilETaylor@javiereguiluz@wouterj@HeahDude@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp