Skip to content

Stdlib: highlight_string()/highlight_file()/show_source() — enum operands must TypeError not LogicException (ext/standard/url.c, php-src-strict) #6486

Description

@PurHur

Category

stdlib · php-src-strict

Problem

highlight_string(), highlight_file(), and show_source() reject non-string operands with LogicException in VM today. Zend/php-src raises catchable TypeError with must be of type string, E given when an enum case is passed — required for parity with other string builtins (#5524 family).

php-src reference

  • php/php-src ext/standard/url.c — PHP_FUNCTION(highlight_string), PHP_FUNCTION(highlight_file)
  • Operand checks: Z_PARAM_STR → TypeError on object/enum

Repro

./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/issue_highlight_enum_typeerror.php

VM (wrong):

highlight_string: LogicException: highlight_string() expects string for argument 1 in this compiler build
highlight_file: LogicException: highlight_file() expects string for argument 1 in this compiler build
show_source: LogicException: highlight_file() expects string for argument 1 in this compiler build

Zend PHP 8.2+:

TypeError: highlight_string(): Argument #1 ($string) must be of type string, E given

Expected

All three builtins use VmString::coerceStringBuiltinArg() / EnumCaseSupport::isEnumCaseVariable() guard → TypeError message matching Zend naming ($string / $filename).

Implementation hints (PHP-in-PHP)

Verification

./script/docker-exec.sh -- php bin/vm.php test/repro-maintainer/issue_highlight_enum_typeerror.php
./script/ci-fast.sh --filter 'highlight_enum'

Related: bootstrap native tokenizer #4824, JIT phase 2 #4366 — this issue is operand typing only.

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