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

Nested Attributes

Arguments of attributes may be literals, such as integer or strings: they can also be other objects.

This feature was introduced in version 8.1. The objects must be created with a new expression, with their respective argument position or name. The created object is not necessarily an attribute itself, and they may also be created with another new expression.

<?php

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

?>

Documentation