From 71b2c47bec7f49061e6cb09485033a09f6feff1a Mon Sep 17 00:00:00 2001 From: Korvin Szanto Date: Sat, 7 Feb 2026 11:36:55 -0800 Subject: [PATCH 1/2] Specify anonymous class attributes --- spec.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec.md b/spec.md index 50fc26e..9ece659 100644 --- a/spec.md +++ b/spec.md @@ -1559,6 +1559,18 @@ $instance = new class ($a) extends \Foo implements }; ``` +If an anonymous class has attributes, they MUST be placed starting on the next line after the `new` keyword, indented +once, and otherwise follow the same rules as other attributes specified in section 12. The remaining anonymous class +declaration after the final attribute MUST keep the same indentation as the attributes: + +```php +$example = new + #[Attribute] + class { + ... + }; +``` + ## 9. Enumerations Enumerations (enums) MUST follow the same guidelines as classes, except where otherwise noted below. From 86e94c0ace5137fd5ecec43454efec50a3bccefc Mon Sep 17 00:00:00 2001 From: Korvin Szanto Date: Wed, 11 Feb 2026 10:04:50 -0800 Subject: [PATCH 2/2] Clarify the placement of the following class declaration Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 9ece659..7c82de6 100644 --- a/spec.md +++ b/spec.md @@ -1561,7 +1561,7 @@ $instance = new class ($a) extends \Foo implements If an anonymous class has attributes, they MUST be placed starting on the next line after the `new` keyword, indented once, and otherwise follow the same rules as other attributes specified in section 12. The remaining anonymous class -declaration after the final attribute MUST keep the same indentation as the attributes: +declaration after the final attribute MUST start on a new line and keep the same indentation as the attributes: ```php $example = new