Req #64176 [Com]: functions calls should accept trailing ,

From: Date: Mon, 22 Oct 2018 09:50:17 +0000
Subject: Req #64176 [Com]: functions calls should accept trailing ,
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217648@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64176&edit=1

 ID:                 64176
 Comment by:         spam2 at rhsoft dot net
 Reported by:        php at paulisageek dot com
 Summary:            functions calls should accept trailing ,
 Status:             Open
 Type:               Feature/Change Request
 Package:            Unknown/Other Function
 Operating System:   All
 PHP Version:        5.4Git-2013-02-08 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

https://ayesh.me/Upgrade-PHP-7.3#caller-trailing-comma


Previous Comments:
------------------------------------------------------------------------
[2018-10-22 09:48:19] jean dot claveau at gmail dot com

Not only function calls could work this way for a smoother workflow, methods and functions
definitions also :

function my_funtion($param1, $param2,)
{
    // ...
}

Especially with a lot of parameters :

function my_funtion(
   $param1, 
   $param2,
   ...,
   $paramN,
) {
    // ...
}

------------------------------------------------------------------------
[2013-02-21 05:36:51] laruence@php.net

for the record, here comes a RFC by Sara:
https://wiki.php.net/rfc/trailing-comma-function-args

------------------------------------------------------------------------
[2013-02-08 21:38:57] php at paulisageek dot com

Description:
------------
In our code we require everyone to put a trailing , in array declarations so that 
blame stays clean. Like when:

$foo = array(
  1,
)

becomes

$foo = array(
  1,
  2,
)

Then only 1 line has changed. But for function calls, when

$foo = foo(
  1
)

becomes

$foo = foo(
  1,
  2
)

now 2 lines blame to you.

Allowing the same syntax for function calls as array creation would be great.

Test script:
---------------
<?php
function id($x) { return $x; }

id(1,);

Expected result:
----------------
It runs.

Actual result:
--------------
Fatal error: syntax error, unexpected ')'


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=64176&edit=1


Thread (5 messages)

« previous php.bugs (#217648) next »