Skip to content

Regression: highlight_string/highlight_file HTML wire — Zend <code><span> + &nbsp; (re-#25419, ext/standard/basic_functions.c) #27827

Closed

Description

@PurHur

Category

bug · php-src-strict · highlight HTML wire · pillar 4

Problem

highlight_string() / highlight_file() / show_source() still emit a non-Zend HTML wire format. Zend 8.2 wraps with <code><span style="color: #000000">… and uses &nbsp; for spaces; this compiler emits a <pre><code style=…> wrapper and ordinary spaces (no &nbsp;). Previously closed as #25419 / #25264 / #25063 / #24662 — still red on master (2026-08-05).

Repro Zend 8.2.32 VM/JIT
highlight_string('<?php echo 1;', true) starts with <code> <pre>
contains &nbsp; yes no
contains <pre> no yes

php-src reference

PHP implementation target

  • ext/standard highlight PHP port — match Zend 8.2 outer <code><span> nesting, &nbsp; spacing, and newline placement around the outer span
  • Keep PROFILE=8.4+ wire identical to the active php-src line if it differs; gate only if php-src changed
  • PHP-in-PHP; no new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc '
cat > /tmp/hl.php <<'"'"'PHP'"'"'
<?php
$html = highlight_string("<?php echo 1;", true);
echo (str_starts_with($html, "<code>") ? "START_CODE" : (str_starts_with($html, "<pre>") ? "START_PRE" : "START_OTHER")), PHP_EOL;
echo (str_contains($html, "&nbsp;") ? "HAS_NBSP" : "NO_NBSP"), PHP_EOL;
echo (str_contains($html, "<pre>") ? "HAS_PRE" : "NO_PRE"), PHP_EOL;
PHP
echo ZEND:; php /tmp/hl.php
echo VM:; php bin/vm.php /tmp/hl.php
echo JIT:; php bin/jit.php /tmp/hl.php
'

Done when

  • VM + JIT match Zend wrapper (START_CODE, HAS_NBSP, NO_PRE) on the host reference profile
  • highlight_file / show_source same wire
  • Compliance .phpt asserts prefix/&nbsp; (not only “contains php”); php-src-strict; no php-compiler-strict shortcut

Gate context (2026-08-05)

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Aug 5, 2026
  2. PurHur commented on Aug 8, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #27165, #27716, #27827)

    Queued after #27165/#27716. Zend highlight HTML wire (<code><span> + &nbsp;, no <pre>).

  3. PurHur commented on Aug 8, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — starting #27827 (batch #27165/#27716/#27827)

    #27165 → #28951, #27716 → #28952 merged. Implementing Zend highlight HTML wire (<code><span> + &nbsp;, no <pre>).

  4. PurHur commented on Aug 8, 2026

    @PurHur
    OwnerAuthor

    Already fixed on master — verified 2026-08-08 @ f9def272f9 in Docker.

    Issue repro Zend / bin/vm.php / bin/jit.php all print START_CODE / HAS_NBSP / NO_PRE. Full highlight_string('<?php echo 1;', true) HTML is byte-identical Zend↔VM↔JIT. highlight_file / show_source same wrapper (CODE NBSP NOPRE).

    Root cause landed earlier: #25063 / #25264 (HighlightEngine::usesPreCodeWrapper withholds <pre><code> on unset PROFILE so reference matches Zend 8.2).

    Closing — no further PR. Batch continues with a replacement stdlib item.

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 machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions