1.2.636. List With Array Appends

List() behavior has changed in PHP 7.0 and it has impact on the indexing when list is used with the [] operator.

The appended values are created in the same order than in the syntax, while in PHP 5.6, it is in the reverse order. In PHP 7.0, results are ::

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
)

In PHP 5.6, results are ::

Array
(
    [0] => 3
    [1] => 2
    [2] => 1
)
<?php

$x = array();
list($x[], $x[], $x[]) = [1, 2, 3];

print_r($x);

?>

1.2.636.1. Connex PHP features

1.2.636.1.1. Suggestions

  • Refactor code to avoid using append in a list() call

1.2.636.1.2. Specs

Short name

Php/ListWithAppends

Rulesets

All, Changed Behavior, CompatibilityPHP70

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Changed Behavior

PHP 7.0

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud