Skip to content

Commit 9dc210d

Browse files
authored
Merge pull request #37 from Crell/anon-classes
Omit () on zero-argument anonymous classes.
2 parents aaf443f + 38d203c commit 9dc210d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

spec.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,20 +1187,27 @@ the list of `implements` interfaces does not wrap. If the list of interfaces
11871187
wraps, the brace MUST be placed on the line immediately following the last
11881188
interface.
11891189

1190+
If the anonymous class has no arguments, the `()` after `class` MUST be omitted.
1191+
11901192
```php
11911193
<?php
11921194

11931195
// Brace on the same line
1196+
// No arguments
11941197
$instance = new class extends \Foo implements \HandleableInterface {
11951198
// Class content
11961199
};
11971200

11981201
// Brace on the next line
1199-
$instance = new class extends \Foo implements
1202+
// Constructor arguments
1203+
$instance = new class($a) extends \Foo implements
12001204
\ArrayAccess,
12011205
\Countable,
12021206
\Serializable
12031207
{
1208+
public function __construct(public int $a)
1209+
{
1210+
}
12041211
// Class content
12051212
};
12061213
```

0 commit comments

Comments
 (0)