Summary
Several stdlib builtins reject enum case operands with LogicException and compiler-specific messages. Zend/php-src rejects them with TypeError via Z_PARAM_STR / internal string checks (php-src-strict).
Affected today on VM:
| Function |
Repro |
Current |
Zend |
json_validate() |
test/repro/maintainer_gap_json_validate_enum.php |
LogicException: argument #1 must be a string in this compiler build |
TypeError |
preg_split() |
test/repro/maintainer_gap_preg_split_enum.php |
LogicException: pattern must be a string… |
TypeError |
preg_grep() |
test/repro/maintainer_gap_preg_grep_enum.php |
LogicException: pattern must be a string… |
TypeError |
preg_quote() |
test/repro/maintainer_gap_preg_quote_enum.php |
LogicException: subject must be a string… |
TypeError |
php-src reference
ext/json/php_json.c — php_json_validate() (Z_PARAM_STR)
ext/pcre/php_pcre.c — php_pcre_split, php_pcre_grep, php_pcre_quote
Repro
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_json_validate_enum.php
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_preg_split_enum.php
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_preg_grep_enum.php
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_preg_quote_enum.php
Zend (any 8.x):
enum E: string { case A = 'x'; }
json_validate(E::A); // TypeError
preg_split(E::A, ''); // TypeError
preg_grep(E::A, []); // TypeError
preg_quote(E::A); // TypeError
Implementation (PHP-in-PHP first)
- VM: replace raw
Variable::TYPE_STRING / VmReflection::stringArg() throws with VmString::coerceStringBuiltinArg() + EnumCaseSupport::isEnumCaseVariable() guard → TypeError with Zend-shaped messages
- Files:
ext/standard/json_validate.php, preg_split.php, preg_grep.php, preg_quote.php
- JIT/AOT: mirror guards in
JitStringBuiltinArg / per-builtin lowerers (JitStringArg::lower paths)
- Do not coerce enum backing scalars
Verification
- Repro scripts catch
TypeError (not LogicException)
- Add
test/compliance/cases/stdlib/json_validate_enum_typeerror.phpt and preg_*_enum_typeerror.phpt
- VM + JIT + AOT when issue scope requires all backends
Summary
Several stdlib builtins reject enum case operands with
LogicExceptionand compiler-specific messages. Zend/php-src rejects them withTypeErrorviaZ_PARAM_STR/ internal string checks (php-src-strict).Affected today on VM:
json_validate()test/repro/maintainer_gap_json_validate_enum.phpLogicException: argument #1 must be a string in this compiler buildTypeErrorpreg_split()test/repro/maintainer_gap_preg_split_enum.phpLogicException: pattern must be a string…TypeErrorpreg_grep()test/repro/maintainer_gap_preg_grep_enum.phpLogicException: pattern must be a string…TypeErrorpreg_quote()test/repro/maintainer_gap_preg_quote_enum.phpLogicException: subject must be a string…TypeErrorphp-src reference
ext/json/php_json.c—php_json_validate()(Z_PARAM_STR)ext/pcre/php_pcre.c—php_pcre_split,php_pcre_grep,php_pcre_quoteRepro
Zend (any 8.x):
Implementation (PHP-in-PHP first)
Variable::TYPE_STRING/VmReflection::stringArg()throws withVmString::coerceStringBuiltinArg()+EnumCaseSupport::isEnumCaseVariable()guard →TypeErrorwith Zend-shaped messagesext/standard/json_validate.php,preg_split.php,preg_grep.php,preg_quote.phpJitStringBuiltinArg/ per-builtin lowerers (JitStringArg::lowerpaths)Verification
TypeError(notLogicException)test/compliance/cases/stdlib/json_validate_enum_typeerror.phptandpreg_*_enum_typeerror.phpt