Nested Attributes

Arguments of attributes may be literals and also objects. The objects must be created with a new expression, in their respective argument position or name. The created object is not necessarily an attribute itself.

<?php

#[
    MyAttribute(
        new OptionA(),
        new OptionB()
    )
]
function headers() : never {
}

?>

Documentation

Added in PHP 8.1+