Skip to content

Improve PHP 8.5 pipe operator formatting - #219

Open
apeschar wants to merge 1 commit into
lkrms:mainfrom
apeschar:preserve-pipe-operator-newlines
Open

Improve PHP 8.5 pipe operator formatting#219
apeschar wants to merge 1 commit into
lkrms:mainfrom
apeschar:preserve-pipe-operator-newlines

Conversation

@apeschar

Copy link
Copy Markdown

Summary

  • classify PHP 8.5's T_PIPE as an operator so spaces are added around |>
  • preserve input newlines before pipe operators, including with operators-first and operators-last modes
  • register the pipe operator's left associativity and precedence between concatenation and comparison
  • add a focused regression test and update existing PHP 8.5 fixtures and generated documentation

Current main turns:

$result = $value
    |> first(...)
    |> second(...);

into:

$result = $value|> first(...)|> second(...);

With this change, multiline chains retain their layout and inline expressions become $value |> first(...) |> second(...).

Validation

  • PHP 8.2: 7,885 tests, 23,715 assertions
  • PHP 8.4: 8,072 tests, 24,287 assertions
  • PHP 8.5: 8,129 tests, 24,458 assertions
  • PHPStan on PHP 8.4
  • generated-file check
  • PHP CS Fixer and pretty-php checks
  • PHAR build and smoke test

@apeschar
apeschar marked this pull request as ready for review August 31, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant