Category
language · php-src-strict
Problem
PHP 8.4 adds the pipe operator |> for left-to-right function application:
$result = "hello" |> strtoupper(...);
// equivalent to strtoupper("hello")
Zend parses T_PIPE in zend_language_parser.y and lowers it in zend_compile.c as a call with the left expression as the first argument.
This compiler rejects the token at parse time — no grammar rule or lowering exists in lib/ / php-cfg.
php-src reference
Repro (failure today)
<?php
$result = "hello" |> strtoupper(...);
echo $result, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
cat >/tmp/repro_pipe.php <<PHP
<?php
\$result = "hello" |> strtoupper(...);
echo \$result, "\n";
PHP
php8.4 /tmp/repro_pipe.php 2>&1 | head -3 # HELLO (when PHP 8.4+ available)
php bin/vm.php /tmp/repro_pipe.php 2>&1 | head -5
'
| Runtime |
Result |
| Zend PHP 8.4+ |
HELLO |
bin/vm.php (today) |
parse error unexpected token ">" |
Chained pipes and nested calls should match Zend once base case works.
Scope (this repo) — PHP-in-PHP first
| Layer |
Path |
| Parser |
php-cfg / lib/SourcePreprocessor/ — add |> token and expression node |
| Compiler |
lib/Compiler.php — lower pipe to call with left expr as first arg to right callable |
| JIT |
lib/JIT.php — reuse normal call lowering |
| Tests |
test/compliance/cases/language/pipe_operator_basic.phpt |
No new C runtime branches — pipe is pure compile-time sugar.
Done when
Related
Category
language· php-src-strictProblem
PHP 8.4 adds the pipe operator
|>for left-to-right function application:Zend parses
T_PIPEinzend_language_parser.yand lowers it inzend_compile.cas a call with the left expression as the first argument.This compiler rejects the token at parse time — no grammar rule or lowering exists in
lib// php-cfg.php-src reference
Zend/zend_language_parser.y—T_PIPE, pipe expression productionZend/zend_compile.c— pipe lowering toZEND_CALL/ first-class callableRepro (failure today)
HELLObin/vm.php(today)unexpected token ">"Chained pipes and nested calls should match Zend once base case works.
Scope (this repo) — PHP-in-PHP first
lib/SourcePreprocessor/— add|>token and expression nodelib/Compiler.php— lower pipe to call with left expr as first arg to right callablelib/JIT.php— reuse normal call loweringtest/compliance/cases/language/pipe_operator_basic.phptNo new C runtime branches — pipe is pure compile-time sugar.
Done when
HELLOon VM matching Zend PHP 8.4+fn(...) |> g(...)and multi-step chains match php-src on minimal matrix./script/ci-fast.sh --filter pipe_operatorgreenRelated
(...)(Language: enum case instance method first-class callable (... ) — compile fails PHPTypes (Zend/zend_compile.c) #9398 enum methods) · North star #1492