From af7a88eb06499251ded4ee0ea21907e6b03012c2 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 5 Oct 2026 22:08:52 +0200 Subject: [PATCH] Support attributes on anonymous classes (new #[Attr] class {}) An attribute group between new and an anonymous class, e.g. new #[AsCommand(name: 'foo')] class extends Command {}, is now parsed and the attribute groups attach to the class node, so it prints back unchanged. Adds zero new goyacc conflicts. --- .../attributes_on_anonymous_class_test.go | 47 + internal/php8/php8.go | 2930 +++++++++-------- internal/php8/php8.y | 11 + 3 files changed, 1529 insertions(+), 1459 deletions(-) create mode 100644 internal/php8/attributes_on_anonymous_class_test.go diff --git a/internal/php8/attributes_on_anonymous_class_test.go b/internal/php8/attributes_on_anonymous_class_test.go new file mode 100644 index 0000000..b13157e --- /dev/null +++ b/internal/php8/attributes_on_anonymous_class_test.go @@ -0,0 +1,47 @@ +package php8_test + +import ( + "bytes" + "testing" + + "github.com/rectorphp/php-parser-in-go/pkg/ast" + "github.com/rectorphp/php-parser-in-go/pkg/visitor/printer" +) + +func TestAttributesOnAnonymousClass(test *testing.T) { + root, parserErrors := parseIntersectionTypes(`