Skip to content

Stdlib: highlight_string() / highlight_file() — syntax-highlighted output (ext/standard parity) #3164

Description

@PurHur

Category

stdlib · php-src-strict · spec refresh 2026-06-20

Problem

highlight_string() / highlight_file() / show_source() (#3447) VM builtins now exist (ext/standard/VmHighlight.php, highlight_string.php, highlight_file.php), but parity is incomplete:

  1. Compile — highlight_file(__DIR__ . '/x.php') fails Expr_MagicScriptConst (Regression: highlight_file()/highlight_string() __FILE__/__DIR__ args still fail compile — re-#9924/#9140 (Zend/zend_compile.c) #9973).
  2. Output bytes — highlight_string($code, return: true) returns string but HTML length/markup differs from Zend (Stdlib: highlight_string() HTML markup wrong vs Zend — output length/spans differ (ext/standard/basic_functions.c) #10308 — len 269 vs 340 on maintainer repro).
  3. JIT — lowering exists (JitHighlight.php); must follow VM SSOT after output parity.

Original umbrella tracked missing functions; this spec now tracks remaining php-src-strict gaps.

php-src reference

Repro

Output parity (#10308):

test/repro/maintainer_gap_highlight_string_bool.php

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_highlight_string_bool.php
php bin/vm.php test/repro/maintainer_gap_highlight_string_bool.php
'

Compile parity (#9973):

test/repro/maintainer_gap_highlight_file_bool.php — VM fails compile on __DIR__ concat today.

Check Zend VM today
highlight_string(..., true) len 269 340
highlight_file(__DIR__.'/sample.php', true) runs compile fail

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/VmHighlight.php, highlight_*.php
Compiler #9973 magic const in call args
JIT ext/standard/JitHighlight.php after VM green
Matrix script/capability-matrix.php

Done when (php-src-strict)

Sub-issues (claim separately)

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

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions