8000 Add support for pipelines with `|>` and `?|>` by thekid · Pull Request #181 · xp-framework/compiler · GitHub
[go: up one dir, main page]

Skip to content

Add support for pipelines with |> and ?|> #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

thekid
Copy link
Member
@thekid thekid commented Mar 27, 2024

This pull request implements support for https://wiki.php.net/rfc/pipe-operator-v3. Additionally, it supports a null-safe version of this operator, ?|>.

Example

$user= $name |> trim(...) |> strtolower(...);

// Equivalent of:
$user= strtolower(trim($name));

Process (initial release)

Process (native support)

  • Wait for PR to be merged and PHP builds on GitHub to pick this up
  • Add PHP 8.5 emitter
  • Create feature release

Incompatibility with by-ref arguments

This implementation doesn't raise errors when piping to a callable requiring references like the original (see Zend/tests/pipe_operator/call_by_ref.phpt) for runtime performance reasons. Rejecting references may be seen as a shortcoming of the PHP implementation, see https://externals.io/message/127336#127344

thekid added 4 commits May 18, 2025 10:00
Once php/php-src#17118 is merged, we can create a PHP 8.5 emitter which
does not include it and emits pipes natively
@thekid
Copy link
Member Author
thekid commented May 18, 2025

Verified test suite with a PHP built from the current pull request and a PHP85 emitter which does not include the EmulatePipelines trait but instead emits native syntax:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0