Skip to content

Regression: highlight_string()/highlight_file() — literal true second arg throws LogicException (ext/standard/url.c) #9140

Description

@PurHur

Summary

highlight_string($code, true) and highlight_file($path, true) fatal with LogicException: highlight_string() expects bool for argument 2 when the second argument is a boolean literal (true/false). Zend accepts the call and returns an HTML string.

Repro

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

Zend (host/php):

type:string
len:222
has_span:yes

This compiler (VM):

PHP Fatal error: Uncaught LogicException: highlight_string() expects bool for argument 2 in this compiler build

php-src reference

  • ext/standard/url.c — PHP_FUNCTION(highlight_string) / highlight_file
  • Second parameter $return is zend_parse_parameters type b (bool); literals must work.

Implementation (PHP-in-PHP)

  • ext/standard/highlight_string.php — resolveIndirect() type check rejects bool literals passed as arg Php stdlib specs implementation #2; align with Zend coercion / Variable::TYPE_BOOLEAN for literal operands.
  • Mirror fix in highlight_file.php / show_source alias if shared path.
  • ext/standard/JitHighlight.php if JIT has same guard.

Done when (php-src-strict)

  • php bin/vm.php test/repro/maintainer_gap_highlight_string_bool.php matches Zend output.
  • Add narrow compliance guard under test/compliance/ or extend existing highlight tests.
  • JIT/AOT agree when in scope.

Related

Regression of closed #3164 / #4824 / #6486.

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