Skip to content

Operator spacing union types / multi-catch expressions #67

Closed
@jrfnl

Description

@jrfnl

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: squizlabs/PHP_CodeSniffer#3663

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions