1.2.401. Ellipsis Usage

Usage of the ellipsis keyword. The keyword is three dots : ... . It is also named variadic or splat operator.

It may be in function definitions and function calls; it may be in arrays; it is also usable with parenthesis.

allows for packing or unpacking arguments into an array.

<?php

$args = [1, 2, 3];
foo(...$args);
// Identical to foo(1,2,3);

function bar(...$a) {
    // Identical to : $a = func_get_args();
}
?>

See also PHP RFC: Syntax for variadic functions, PHP 5.6 and the Splat Operator and Variable-length argument lists.

1.2.401.1. Specs

Short name

Php/EllipsisUsage

Rulesets

All, Appinfo, CE, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55

Exakat since

0.8.4

PHP Version

With PHP 5.6 and more recent

Severity

Major

Time To Fix

Slow (1 hour)

Precision

Very high

Features

ellipsis

Available in

Entreprise Edition, Community Edition, Exakat Cloud