Skip to content

Commit

Permalink
Merge pull request #109 from WordPress/object-instantiation
Browse files Browse the repository at this point in the history
Object instantiation
  • Loading branch information
dingo-d authored Sep 28, 2022
2 parents 54ada87 + aa247a9 commit ffd11af
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions wordpress-coding-standards/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,22 @@ class Foo {
- Readonly classes are available since PHP 8.2.
[/info]

### Object Instantiation

When instantiating a new object instance, parenthesis must always be used, even when not strictly necessary.
There should be no space between the name of the class being instantiated and the opening parenthesis.

```php
// Correct.
$foo = new Foo();
$anonymous_class = new class( $parameter ) { ... };
$instance = new static();

// Incorrect.
$foo = new Foo;
$anonymous_class = new class ( $input ) { ... };
```

## Control Structures

### Use `elseif`, not `else if`
Expand Down

0 comments on commit ffd11af

Please sign in to comment.