# RFC: Revisit trailing commas in function arguments

- Status: Withdrawn
- Authors: Sammy Kaye Powers, me@sammyk.me
- Date: 2015-10-07
- Version: 0.1
- Original: https://wiki.php.net/rfc/revisit-trailing-comma-function-args
- Page: https://externals.io/rfc/revisit-trailing-comma-function-args
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Discussions on the mailing list

- [\[RFC\]\[DISCUSSION\] Revisit trailing commas in function arguments](https://externals.io/message/88791.md) — started on 2015-10-14, 22 messages

---

## Introduction

Arrays in PHP have long since supported trailing commas.

#### Trailing array commas

```php
$foo = [
    'foo',
    'bar',
];
```

This makes for clean diffs and easy appending of new values in user-land.

Unfortunately, the argument list for function/method declarations and calls do not share the same luxury.

#### Declarations raise a parse error

```php
// Parse error
function myFunc(
    $foo,
    $bar,
    ) {
  /* ... */
}
```

#### Calls raise a parse error

```php
// Parse error
myFunc(
    $foo,
    $bar,
    );
```

## Proposal

This RFC proposes allowing function/method declarations and calls to allow for trailing commas in order to:

1. Offer a consistent API and match the existing array functionality.
2. Make it easy to append new arguments in user-land.
3. Have cleaner diffs (so only one line shows up as being modified when appending arguments instead of two).
4. Match what [HHVM did a while ago](https://github.com/facebook/hiphop-php/commit/c1b7da6a4c128af5ddfc75f515c205de9f417a1e).

## Backward Incompatible Changes

This change would have no breaking changes.

## Proposed PHP Version

PHP 7.1

## Proposed Voting Choices

Project requires a 2/3 majority.

## Patches and Tests

The [original patch by Sara Golemon](https://github.com/sgolemon/php-src/compare/master...trailing-comma).
