Skip to content

Language: pipe operator (|>) — PHP 8.4 parse + compile missing (Zend/zend_language_parser.y) #9750

Description

@PurHur

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

  • Repro compiles and prints HELLO on VM matching Zend PHP 8.4+
  • fn(...) |> g(...) and multi-step chains match php-src on minimal matrix
  • JIT/AOT agree with VM on repro (or documented follow-up)
  • ./script/ci-fast.sh --filter pipe_operator green

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    IMPORTANTCritical patharea:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions