per-coding-style
per-coding-style copied to clipboard
Operator spacing union types / multi-catch expressions
I believe some clarification is needed about the spacing requirements around the |
operator when used in the following two situations:
- Union types
- Multi-catch statements
At this moment, most coding standards I'm aware of use "no spaces around the |
operator" as a rule for union types.
However, multi-catch statements predate union types and the example in section 5.6 had spaces around the |
operator.
PHPCS has taken the literal interpretation based on the example and expects one space on either side of the |
operator in multi-catch statements.
CS-Fixer treats the |
in multi-catch as if it were a union type, expecting no spaces.
End-users are confused ;-/
Ref: https://github.com/squizlabs/PHP_CodeSniffer/issues/3663