Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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() {}

?>

Alternatives

  • Remove the three dots from the attribute.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See