Skip to content

Commit

Permalink
Add property and method modifier order chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
dingo-d committed Sep 9, 2022
1 parent b73bb2a commit fbb5370
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions wordpress-coding-standards/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,32 @@ _Usage in WordPress Core_

Visibility for class constants can not be used in WordPress Core until the minimum PHP version has been raised to PHP 7.1.

### Property and method modifier order

When using multiple modifiers for a property or method declaration, the order should be as follows:

1. First the optional `abstract` or `final` keyword.
2. Next a visibility keyword.
3. Lastly, the optional `static` keyword.

```php
// Correct.
abstract class Foo {
public static $foo;

abstract protected static function bar();
}

// Incorrect.
abstract class Foo {
static public $foo;

static protected final function bar() {
// Code.
};
}
```

## Control Structures

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

0 comments on commit fbb5370

Please sign in to comment.