smarty-php / smarty-php/smarty

use a trailing comma in arrays

Open
#1,013 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
2.3k
Forks
709
PR merge metrics
No merged PRs in 30d

Description

While I am at it, things like:

{$a=[
  'foo',
  'bar',
  'baz',
]}

are not possible at the moment (because of the trailing comma). PHP supports this syntax for quite a while, so IMO Smarty should do it as well. IMO (but as I said, I am not really good with parsers), a small change should to the trick:

arrayelements(res)   ::=  arrayelements(a1) COMMA arrayelement(a).  {
    res = a1.','.a;
}
arrayelements(res)   ::=  arrayelement(a1) COMMA arrayelements(a).  {
    res = a1.','.a;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies the arrayelements grammar productions as the entry point; start by locating the parser grammar that handles array elements and compare it with the trailing-comma PHP example. Done means the example parses successfully while existing array syntax remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.