Skip to content

Stdlib: enum operand TypeError for json_validate/preg_quote/preg_split (#5999) - #7642

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-5999-enum-typeerror
Jun 8, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-5999-enum-typeerror

Conversation

@PurHur

@PurHur PurHur commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace LogicException string-type checks with VmString::coerceStringBuiltinArg() on VM for json_validate(), preg_quote(), and preg_split() subject
  • Mirror guards in JIT/AOT via JitStringBuiltinArg (JitJsonValidate, preg_quote, preg_split)
  • preg_grep() pattern already used VmReflection::stringArg; added compliance lock-in only

php-src refs: ext/json/php_json.c (php_json_validate), ext/pcre/php_pcre.c (php_pcre_quote, php_pcre_split, php_pcre_grep)

Closes #5999

Verification

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
for f in test/repro/maintainer_gap_json_validate_enum.php \
         test/repro/maintainer_gap_preg_quote_enum.php \
         test/repro/maintainer_gap_preg_split_enum.php \
         test/repro/maintainer_gap_preg_grep_enum.php; do
  php bin/vm.php "$f"
done
vendor/bin/phpunit --filter "json_validate_enum_typeerror|preg_quote_enum_typeerror|preg_split_enum_typeerror|preg_grep_enum_typeerror"
vendor/bin/phpunit --filter PregEnumTypeerrorJitCompileTest
'

Output (2026-06-08):

TypeError: json_validate(): Argument #1 ($json) must be of type string, E given
TypeError: preg_quote(): Argument #1 ($str) must be of type string, E given
TypeError: preg_split(): Argument #1 ($pattern) must be of type string, E given
TypeError: preg_grep(): Argument #1 ($pattern) must be of type string, E given
OK (6 tests, 6 assertions)  # compliance VM+JIT
OK (2 tests, 6 assertions)  # AOT compile-only lint

Made with Cursor

…plit (#5999).

Replace LogicException string-type checks with VmString::coerceStringBuiltinArg and JitStringBuiltinArg so enum cases get Zend-shaped TypeError messages on VM, JIT, and AOT.

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: json_validate()/preg_split()/preg_grep()/preg_quote() — enum operands must TypeError not LogicException (php-src-strict)

1 participant