Open
Conversation
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
[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(...); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think this should work, not sure how smart we should be about rejecting non-callables in right side of pipeline operator.