php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74810 Something odd about ordering of func_get_args() result in 7.2
Submitted: 2017-06-24 21:40 UTC Modified: -
From: daverandom@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.2.0alpha2 OS: Any
Private report: No CVE-ID: None
 [2017-06-24 21:40 UTC] daverandom@php.net
Description:
------------
When using func_get_args() in combination with array_slice() in 7.2, the results are incorrect. Hard to succinctly describe, see code sample.

https://3v4l.org/oSFoM

Test script:
---------------
<?php

function test_func_get_args() {
    var_dump(func_get_args()); // as expected
}

function test_array_slice($array) {
    var_dump(array_slice($array, 1)); // as expected
}

function test_array_slice_with_func_get_args() {
    var_dump(array_slice(func_get_args(), 1)); // ???
}

$input = [1, 2, 3];

echo "=-=-=-= TEST func_get_args() =-=-=-=\n";
test_func_get_args(...$input);

echo "\n=-=-=-= TEST array_slice() =-=-=-=\n";
test_array_slice($input);

echo "\n=-=-=-= TEST 3 =-=-=-=\n";
test_array_slice_with_func_get_args(...$input);

Expected result:
----------------
=-=-=-= TEST func_get_args() =-=-=-=
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

=-=-=-= TEST array_slice() =-=-=-=
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}

=-=-=-= TEST 3 =-=-=-=
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}

Actual result:
--------------
=-=-=-= TEST func_get_args() =-=-=-=
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

=-=-=-= TEST array_slice() =-=-=-=
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}

=-=-=-= TEST 3 =-=-=-=
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-25 14:00 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ed37ca7369c7891cdbe7795ce96ad46dad7c1d26
Log: Fixed bug #74810
 [2017-06-25 14:00 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 05:01:32 2024 UTC