Skip to content

Commit

Permalink
Add object instantiation chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
dingo-d committed Sep 26, 2022
1 parent 54ada87 commit ea47837
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() { ... };
$instance = new static();

// Incorrect.
$foo = & new Foo;
$foo = new Foo ();
```

## Control Structures

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

0 comments on commit ea47837

Please sign in to comment.