Skip to content

fix: Unify the usage of () after class instances (including anonymous classes) #24

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

Closed
Closed
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: 6 additions & 3 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1055,24 +1055,27 @@ in the above section.
```php
<?php

$instance = new class {};
$instance = new class () {};
```

The opening brace MAY be on the same line as the `class` keyword so long as
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.

This also includes the use of parentheses due to directly instantiating the
declared class.

```php
<?php

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

// Brace on the next line
$instance = new class extends \Foo implements
$instance = new class () extends \Foo implements
\ArrayAccess,
\Countable,
\Serializable
Expand Down