====== PHP RFC: Revisit trailing commas in function arguments ======
* Version: 0.1
* Date: 2015-10-07
* Author: Sammy Kaye Powers, me@sammyk.me
* Status: Withdrawn in favor of [[https://wiki.php.net/rfc/list-syntax-trailing-commas|Trailing Commas In List Syntax]] RFC
* First Published at: https://wiki.php.net/rfc/trailing-comma-function-args
===== Introduction =====
Arrays in PHP have long since supported trailing commas.
=== Trailing array commas ===
$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 ===
// Parse error
function myFunc(
$foo,
$bar,
) {
/* ... */
}
=== Calls raise a parse error ===
// Parse error
myFunc(
$foo,
$bar,
);
===== Proposal =====
This RFC proposes allowing function/method declarations and calls to allow for trailing commas in order to:
- Offer a consistent API and match the existing array functionality.
- Make it easy to append new arguments in user-land.
- Have cleaner diffs (so only one line shows up as being modified when appending arguments instead of two).
- Match what [[https://github.com/facebook/hiphop-php/commit/c1b7da6a4c128af5ddfc75f515c205de9f417a1e|HHVM did a while ago]].
===== 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 [[https://github.com/sgolemon/php-src/compare/master...trailing-comma|original patch by Sara Golemon]].