You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multi-catch pipe: PSR12 OperatorSpacing requires spaces, union types forbid them #88
TypeSeparatorSpacing doesn't look at catch, and the PSR12.Operators.OperatorSpacing the ruleset inherits treats the | as a bitwise operator. php-cs-fixer's @PER-CS3x0 set writes it like a union type, with no spaces. cakephp/cakephp#19740 had to silence both PSR12 codes in its phpcs.xml for exactly this, and that also silenced them for real bitwise operators.
Proposal: treat the | in a catch type list like a union type separator. No spaces, fixable, and the PSR12 sniff skips it.
Proposed here as PR #94: a repo-owned OperatorSpacing extending the PSR12 sniff keeps every inherited check and treats the catch-list | like a union type separator (no spaces, fixable), so the inherited NoSpaceBefore/NoSpaceAfter no longer fire on it. The catch parenthesis owner identifies the context, so real bitwise operators in the catch body keep their spacing rule. Unit tests + PHPStan level 8 + the repo cs-check are clean.
Yes. The new sniff extends the repo's own PSR12 OperatorSpacing sniff, so every inherited check stays on and only the catch-list | rule changes. The PR code was also run through the repo cs-check and PHPStan level 8 before pushing, both clean.
Activity
XRafik commentedon Oct 25, 2026
Proposed here as PR #94: a repo-owned OperatorSpacing extending the PSR12 sniff keeps every inherited check and treats the catch-list | like a union type separator (no spaces, fixable), so the inherited NoSpaceBefore/NoSpaceAfter no longer fire on it. The catch parenthesis owner identifies the context, so real bitwise operators in the catch body keep their spacing rule. Unit tests + PHPStan level 8 + the repo cs-check are clean.
dereuromark commentedon Oct 26, 2026
Thx anyway!
You are using the sniffer rules too?
XRafik commentedon Oct 26, 2026
Yes. The new sniff extends the repo's own PSR12 OperatorSpacing sniff, so every inherited check stays on and only the catch-list | rule changes. The PR code was also run through the repo cs-check and PHPStan level 8 before pushing, both clean.