Skip to content

Commit 05a8d67

Browse files
authored
Merge pull request #1598 from WordPress-Coding-Standards/feature/operatorspacing-add-instanceof
OperatorSpacing: check spacing around `instanceof` operator
2 parents 56ddcef + abab1cb commit 05a8d67

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class OperatorSpacingSniff extends PHPCS_Squiz_OperatorSpacingSniff {
5454
public function register() {
5555
$tokens = parent::register();
5656
$tokens[ \T_BOOLEAN_NOT ] = \T_BOOLEAN_NOT;
57+
$tokens[ \T_INSTANCEOF ] = \T_INSTANCEOF;
5758
$logical_operators = Tokens::$booleanOperators;
5859

5960
// Using array union to auto-dedup.

WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ if ( $a === $b
6464

6565
if ( $a === $b or
6666
$b === $c ) {}
67+
68+
// Instanceof
69+
if ( MyClass instanceof SomeOtherClass ) {}
70+
if ( MyClass instanceof SomeOtherClass ) {}

WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ if ( $a === $b
6464

6565
if ( $a === $b or
6666
$b === $c ) {}
67+
68+
// Instanceof
69+
if ( MyClass instanceof SomeOtherClass ) {}
70+
if ( MyClass instanceof SomeOtherClass ) {}

WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function getErrorList() {
4242
49 => 2,
4343
50 => 2,
4444
51 => 2,
45+
69 => 2,
4546
);
4647
}
4748

0 commit comments

Comments
 (0)