Skip to content

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

@thekid
Copy link
Member Author

thekid commented May 28, 2025

RFC has passed, see https://externals.io/message/127336#127490

@thekid thekid merged commit 651cd92 into master May 28, 2025
14 checks passed
@thekid thekid deleted the feature/pipelines branch May 28, 2025 19:31
@thekid thekid mentioned this pull request May 28, 2025
@thekid
Copy link
Member Author

thekid commented May 28, 2025

Released (albeit without native support, which will have to wait for the php-src PR to be merged) in https://github.com/xp-framework/compiler/releases/tag/v9.5.0

@thekid
Copy link
Member Author

thekid commented Jun 14, 2025

albeit without native support

See PR #187

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