Skip to content

Commit 70dbcc1

Browse files
committed
Omit () on zero-argument anonymous classes.
1 parent 89fbefa commit 70dbcc1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spec.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,20 +1187,25 @@ 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) {}
12041209
// Class content
12051210
};
12061211
```

0 commit comments

Comments
 (0)