From 95904f3fb0d95bcced99005949eebad71bf40a10 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 5 Mar 2024 09:23:30 +0100 Subject: [PATCH] WhiteSpace/OperatorSpacing: add extra test 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. --- WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc | 4 ++++ WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc index e58abf8cd0..eed51cbd42 100644 --- a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc +++ b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc @@ -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); diff --git a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed index 43ab5ae914..ef8fa828b2 100644 --- a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed +++ b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed @@ -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);