Skip to content

Stdlib: highlight_*()/show_source() enum operands TypeError (#6486) - #6498

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-6486-highlight-enum-typeerror
Jun 6, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-6486-highlight-enum-typeerror

Conversation

@PurHur

@PurHur PurHur commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace manual TYPE_STRING checks (which threw uncatchable LogicException) with VmString::coerceStringBuiltinArg() on highlight_string(), highlight_file(), and show_source() so backed enum case operands raise catchable TypeError matching php-src ext/standard/url.c (Z_PARAM_STR).
  • Extract highlight_file::run() so the show_source alias reports the correct function name in error messages.
  • Add maintainer repro + compliance PHPT.

php-src reference: ext/standard/url.c — PHP_FUNCTION(highlight_string), PHP_FUNCTION(highlight_file)

PHP implementation: ext/standard/highlight_string.php, highlight_file.php, show_source.php

Closes #6486

Verification

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

Output:

highlight_string: TypeError: highlight_string(): Argument #1 ($string) must be of type string, E given
highlight_file: TypeError: highlight_file(): Argument #1 ($filename) must be of type string, E given
show_source: TypeError: show_source(): Argument #1 ($filename) must be of type string, E given
./script/docker-exec.sh -- bash -lc './vendor/bin/phpunit --filter highlight_enum test/compliance/'
OK (1 test, 1 assertion)
./script/docker-exec.sh -- bash -lc './vendor/bin/phpunit --filter "highlight_string|highlight_enum" test/compliance/'
OK, but incomplete, skipped, or risky tests!
Tests: 4, Assertions: 4, Skipped: 1.

Note: highlight builtins remain VM-only per existing capability matrix (#3164); no AOT/JIT lowering change in this PR.

Made with Cursor

Use VmString::coerceStringBuiltinArg() so backed enum cases raise catchable
TypeError matching php-src ext/standard/url.c Z_PARAM_STR, not LogicException.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant