Skip to content

Initial support for PHP 8.5 Pipe Operator #1164

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 2 commits into
base: main
Choose a base branch
from
Open

Conversation

cseufert
Copy link
Collaborator

I think this should work, not sure how smart we should be about rejecting non-callables in right side of pipeline operator.

@cseufert cseufert requested a review from Copilot July 18, 2025 11:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds initial support for PHP 8.5's pipe operator (|>) to the parser. The implementation allows chaining expressions using the pipe operator syntax, enabling functional programming patterns where the output of one expression becomes the input to the next.

  • Adds lexer support for recognizing the |> token sequence
  • Implements parser logic to handle pipe operator expressions as binary operations
  • Includes version checking to ensure PHP 8.5+ requirement is enforced

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tokens.js Defines the new T_PIPE token constant
src/lexer/tokens.js Adds lexer logic to recognize `
src/parser/expr.js Implements pipe operator parsing with version validation
test/snapshot/pipe.test.js Adds test case for basic pipe operator functionality
test/snapshot/__snapshots__/pipe.test.js.snap Generated snapshot for pipe operator test

Comment on lines +122 to +124
// extra operations :
// $a = "Hi" |> strtoupper(...);
if (this.token === this.tok.T_PIPE) {
Copy link
Preview

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment placement is inconsistent with the existing code structure. This comment should be moved to line 124 to directly precede the pipe operator implementation, matching the pattern used for other operators like the coalesce operator.

Suggested change
// extra operations :
// $a = "Hi" |> strtoupper(...);
if (this.token === this.tok.T_PIPE) {
if (this.token === this.tok.T_PIPE) {
// extra operations :
// $a = "Hi" |> strtoupper(...);

Copilot uses AI. Check for mistakes.

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