php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78993 Ellipsis inconsistency
Submitted: 2019-12-19 07:35 UTC Modified: 2019-12-19 14:41 UTC
From: imbolk at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.4.1 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: imbolk at gmail dot com
New email:
PHP Version: OS:

 

 [2019-12-19 07:35 UTC] imbolk at gmail dot com
Description:
------------
It seems to me that there is an inconsistency in the PHP syntax associated with T_ELLIPSIS.

Test script:
---------------
$a = [[1,2,3], [4,5,6]];
var_dump(...($a));
var_dump(...(...($a)));

Expected result:
----------------
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
array(3) {
  [0]=>
  int(4)
  [1]=>
  int(5)
  [2]=>
  int(6)
}

array(6) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(4)
  [4]=>
  int(5)
  [5]=>
  int(6)
}

Actual result:
--------------
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
array(3) {
  [0]=>
  int(4)
  [1]=>
  int(5)
  [2]=>
  int(6)
}

PHP Parse error:  syntax error, unexpected '...' (T_ELLIPSIS) in Command line code on line…

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-19 08:01 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-12-19 08:01 UTC] requinix@php.net
T_ELLIPSIS can only be used in an array or as a function argument. It unpacks an expression, and it is not an expression itself.
 [2019-12-19 08:54 UTC] imbolk at gmail dot com
What about var_dump(...($a));?

($a) is not expression?
 [2019-12-19 08:58 UTC] d8150650 at urhen dot com
BTW var_dump(...[[1],2,3][0]); works fine.
 [2019-12-19 14:13 UTC] imbolk at gmail dot com
Oh yes! What about something like this:

const ONE=1;
var_dump(...array_map(null, [1,2],[3,4])[ONE/ONE-1]);

It's works! Isn't that an expression?
 [2019-12-19 14:41 UTC] nikic@php.net
Of course you can use anything to the right of "...". The point is that "...expr" in itself is not an expression. What is "$a = ...$b" supposed to mean, for example? Only the call(...expr) and [...expr] have any well-defined meaning, and only they are supported.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC