Skip to content

Commit

Permalink
WhiteSpace/OperatorSpacing: add extra test
Browse files Browse the repository at this point in the history
Upstream a PR is open - and will be merged soon - to change the protection against the `Squiz` sniff, which this sniff extends, handling operators found in `declare()` statements.
In particular, the PR is about how the sniff handles parse errors/live coding for declare statements.

As the WPCS sniff calls the parent `register()` method and falls through to the parent `process()` method, the WPCS sniff should automatically get that extra protection too.

This commit just adds an extra test to the `WordPress.WhiteSpace.OperatorSpacing` to safeguard things.
  • Loading branch information
jrfnl committed Mar 5, 2024
1 parent d15a466 commit 95904f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ function fooBar( TypeA&namespace\TypeB $param ) : \TypeC&Partially\Qualified {}
class Foo {
public readonly int|string $prop;
}

// Safeguard that declare statements are ignored.
// Ref: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/289
declare(ticks=1);
4 changes: 4 additions & 0 deletions WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ function fooBar( TypeA&namespace\TypeB $param ) : \TypeC&Partially\Qualified {}
class Foo {
public readonly int|string $prop;
}

// Safeguard that declare statements are ignored.
// Ref: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/289
declare(ticks=1);

0 comments on commit 95904f3

Please sign in to comment.