From 44b3221f415407ea7255cab9091f91e9d46c3a2b Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Fri, 9 Jan 2026 12:02:14 +0100 Subject: [PATCH 1/4] feat(PSR12.Operators.OperatorSpacing): Add documentation for perCompatible setting --- wiki/Customisable-Sniff-Properties.md | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/wiki/Customisable-Sniff-Properties.md b/wiki/Customisable-Sniff-Properties.md index 9ee7e9d..ffdf5e5 100644 --- a/wiki/Customisable-Sniff-Properties.md +++ b/wiki/Customisable-Sniff-Properties.md @@ -1093,8 +1093,34 @@ This sniff checks the depth of imported namespaces inside compound use statement ``` -

back to top

+### PSR12.Operators.OperatorSpacing + +| Property Name | Type | Default | Available Since | +| ------------- | ------ | ------- | --------------- | +| perCompatible | string | 1.0 | 4.0.2 | + +This sniff checks the spacing around operators. By default, this sniff is compatible with [PER Coding Style](https://www.php-fig.org/per/coding-style/) 1.0. The setting `perCompatible` can be set to 3.0 or higher to get different behaviour for spacing around multi-catch `|` operators. +```xml + + + + + +``` + +Valid: no spaces around the '|' operator in a multi-catch with 'perCompatible=3.0' (or higher): +```php +try { +} catch (Exception|RuntimeException $e) { +} +``` +Invalid: spaces around the '|' operator in a multi-catch with 'perCompatible=3.0' (or higher). +```php +try { +} catch (Exception | RuntimeException $e) { +} +``` +

back to top

+ ## Squiz Sniffs From faa9a0aacb16799d0418cc8d9fbaf6fa060b8d0a Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 25 Jan 2026 17:34:10 +0100 Subject: [PATCH 2/4] Apply suggestion from @jrfnl fixing wording and links Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- wiki/Customisable-Sniff-Properties.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wiki/Customisable-Sniff-Properties.md b/wiki/Customisable-Sniff-Properties.md index ffdf5e5..cddfab5 100644 --- a/wiki/Customisable-Sniff-Properties.md +++ b/wiki/Customisable-Sniff-Properties.md @@ -1099,7 +1099,10 @@ This sniff checks the depth of imported namespaces inside compound use statement | ------------- | ------ | ------- | --------------- | | perCompatible | string | 1.0 | 4.0.2 | -This sniff checks the spacing around operators. By default, this sniff is compatible with [PER Coding Style](https://www.php-fig.org/per/coding-style/) 1.0. The setting `perCompatible` can be set to 3.0 or higher to get different behaviour for spacing around multi-catch `|` operators. +This sniff ensures there is at least one space before and after an operator as per [PSR 12](https://www.php-fig.org/psr/psr-12/)/PER Coding Style 1.0. + +As of [PER Coding Style 3.0](https://github.com/php-fig/per-coding-style/blob/3.0.0/spec.md), the spacing requirements for the pipe operator in a multi-`catch` condition have changed to "no spaces around the operator". +By setting the `perCompatible` property to `'3.0'`or higher, the behaviour of the sniff will reflect the changed PER requirements for multi-catch `|` operators. ```xml From 79f2ee9dc7807b746de71789ae6b0ebb3aee8b60 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 25 Jan 2026 17:37:22 +0100 Subject: [PATCH 3/4] implement review comments --- wiki/Customisable-Sniff-Properties.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/wiki/Customisable-Sniff-Properties.md b/wiki/Customisable-Sniff-Properties.md index ffdf5e5..1219c5f 100644 --- a/wiki/Customisable-Sniff-Properties.md +++ b/wiki/Customisable-Sniff-Properties.md @@ -1093,11 +1093,20 @@ This sniff checks the depth of imported namespaces inside compound use statement ``` +

back to top

+ + ### PSR12.Operators.OperatorSpacing + + | Property Name | Type | Default | Available Since | | ------------- | ------ | ------- | --------------- | -| perCompatible | string | 1.0 | 4.0.2 | +| perCompatible | string | 1.0 | 4.1.0 | This sniff checks the spacing around operators. By default, this sniff is compatible with [PER Coding Style](https://www.php-fig.org/per/coding-style/) 1.0. The setting `perCompatible` can be set to 3.0 or higher to get different behaviour for spacing around multi-catch `|` operators. @@ -1122,12 +1131,6 @@ try { } ``` - -

back to top

From 3c1c36fe2e1c9463763065ea2b36a554514ba300 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Wed, 4 Mar 2026 13:19:06 +0100 Subject: [PATCH 4/4] rewrite example to not duplicate XML docs --- wiki/Customisable-Sniff-Properties.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/wiki/Customisable-Sniff-Properties.md b/wiki/Customisable-Sniff-Properties.md index 22d9dba..b1feb47 100644 --- a/wiki/Customisable-Sniff-Properties.md +++ b/wiki/Customisable-Sniff-Properties.md @@ -1121,16 +1121,13 @@ By setting the `perCompatible` property to `'3.0'`or higher, the behaviour of th ``` -Valid: no spaces around the '|' operator in a multi-catch with 'perCompatible=3.0' (or higher): +Example: ```php try { +// Valid with setting perCompatible >= 3.0. } catch (Exception|RuntimeException $e) { -} -``` -Invalid: spaces around the '|' operator in a multi-catch with 'perCompatible=3.0' (or higher). -```php -try { -} catch (Exception | RuntimeException $e) { +// Valid with setting perCompatible < 3.0. +} catch (OtherException | AnotherException $e) { } ```