doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Trailing comma in function calls not documented

Open wb027 opened this issue 3 years ago • 3 comments

Upd. The bug appeared for a different reason.

_From manual page: https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list

I did tests on versions: 7.2 -> PHP Parse error: syntax error, unexpected ')' 7.4 -> it works

wb027 avatar Oct 21 '22 04:10 wb027

I don't know what code you tried but examples 11 and 12 work since at least PHP 7.0, which is the oldest version of PHP that the manual is intended to cover.

damianwadley avatar Oct 21 '22 04:10 damianwadley

Oops! The bug appeared for a different reason.

screen php7 2 $ ./test.php PHP Parse error: syntax error, unexpected ')' in /home/onotole/1/test.php on line 6

screen php7 4 It works.

Ubuntu 20.04 server. Repo: https://launchpad.net/~ondrej/+archive/ubuntu/php

wb027 avatar Oct 21 '22 05:10 wb027

7.2 -> PHP Parse error: syntax error, unexpected ')'

This is due to https://wiki.php.net/rfc/trailing-comma-function-calls; only available as of PHP 7.3.0, and apparently not documented. I could only find the trailing comma in function signatures, but not in calls.

cmb69 avatar Oct 21 '22 08:10 cmb69