Skip to content

Omit () on zero-argument anonymous classes. #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1187,20 +1187,27 @@ the list of `implements` interfaces does not wrap. If the list of interfaces
wraps, the brace MUST be placed on the line immediately following the last
interface.

If the anonymous class has no arguments, the `()` after `class` MUST be omitted.

```php
<?php

// Brace on the same line
// No arguments
$instance = new class extends \Foo implements \HandleableInterface {
// Class content
};

// Brace on the next line
$instance = new class extends \Foo implements
// Constructor arguments
$instance = new class($a) extends \Foo implements
\ArrayAccess,
\Countable,
\Serializable
{
public function __construct(public int $a)
{
}
// Class content
};
```
Expand Down