Cannot create Closure as attribute argument

Description

It is possible to use ... in a function call, but not as an attribute, as it leads to create a PHP closure, which does not carry the Attribute attribute (sic). It also makes little sense, though the PHP parser accepts it, but not the linter.

Example

<?php

#[Foo(...)]
function goo() {}

?>

Solutions

  • Remove the three dots from the attribute.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.