Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow trailing commas in macros + functions + filters #3363

Merged
merged 1 commit into from
Jul 6, 2020
Merged

Allow trailing commas in macros + functions + filters #3363

merged 1 commit into from
Jul 6, 2020

Conversation

apfelbox
Copy link
Contributor

@apfelbox apfelbox commented Jul 6, 2020

I implemented support for trailing commas in

  • function calls
  • filter arguments
  • macro parameters + arguments (so call + definition)

Lists + maps are already supported https://twigfiddle.com/6atiz3

Is something missing?

@apfelbox apfelbox mentioned this pull request Jul 6, 2020
// if the comma above was a trailing comma, early exit the argument parse loop
if ($stream->test(/* Token::PUNCTUATION_TYPE */ 9, ')')) {
break;
}
Copy link
Contributor Author

@apfelbox apfelbox Jul 6, 2020

Choose a reason for hiding this comment

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

The nice part of this addition here is that it prevents usage with no arguments.

So _self.test(a,) is allowed as macro call, _self.test(,) isn't however.

CHANGELOG Outdated Show resolved Hide resolved
@apfelbox apfelbox changed the base branch from 3.x to 1.x July 6, 2020 11:05
@apfelbox
Copy link
Contributor Author

apfelbox commented Jul 6, 2020

@fabpot rebased + update the target branch to also include it in v1.

@fabpot
Copy link
Contributor

fabpot commented Jul 6, 2020

Thank you @apfelbox.

@fabpot fabpot merged commit aa182ff into twigphp:1.x Jul 6, 2020
@apfelbox apfelbox deleted the trailing-commas branch July 6, 2020 12:54
@apfelbox apfelbox mentioned this pull request Jul 6, 2020
fabpot added a commit that referenced this pull request Jul 6, 2020
This PR was merged into the 1.x branch.

Discussion
----------

Unify code style

I noticed that the code style in `ExpressionParser` changed from v1 to v3. So this PR now fixes it, that the file in v1 looks more clean.

@fabpot this is a small addendum to #3363

Commits
-------

38cb89c Unify code style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants