Category
stdlib · php-src-strict
Problem
class_alias() argument #2 ($alias) must be string. Enum case operands must TypeError (php-src Z_PARAM_STR), not LogicException abort. Pairs #5817 / #6561 enum-case string builtin pattern.
Verified probe (2026-06-06):
| Call |
Zend PHP 8.2 |
VM (today) |
class_alias('stdClass', E::A) |
TypeError: class_alias(): Argument #2 ($alias) must be of type string, E given |
LogicException: class_alias() alias must be a string in this compiler build (exit 255) |
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "enum E: string { case A=\"a\"; } try { class_alias(\"stdClass\", E::A); } catch (Throwable \$t) { echo get_class(\$t), \": \", \$t->getMessage(); }"'
Scope
| Module |
Path |
| VM |
ext/standard/class_alias.php — VmString::coerceStringBuiltinArg() for original + alias |
| JIT |
matching JitStringBuiltinArg lowering |
| Tests |
test/compliance/cases/stdlib/class_alias_enum_case_typeerror.phpt |
Done when
- Enum case alias operand throws catchable
TypeError on VM/JIT/AOT
- Valid string aliases unchanged (including enum type aliases tracked by
#5457)
- Compliance
.phpt passes
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter class_alias_enum_case_typeerror'
Category
stdlib· php-src-strictProblem
class_alias()argument #2 ($alias) must bestring. Enum case operands mustTypeError(php-srcZ_PARAM_STR), notLogicExceptionabort. Pairs #5817 / #6561 enum-case string builtin pattern.Verified probe (2026-06-06):
class_alias('stdClass', E::A)TypeError: class_alias(): Argument #2 ($alias) must be of type string, E givenLogicException: class_alias() alias must be a string in this compiler build(exit 255)php-src reference
ext/standard/basic_functions.c—PHP_FUNCTION(class_alias)Repro
Scope
ext/standard/class_alias.php—VmString::coerceStringBuiltinArg()for original + aliasJitStringBuiltinArgloweringtest/compliance/cases/stdlib/class_alias_enum_case_typeerror.phptDone when
TypeErroron VM/JIT/AOT#5457).phptpassesVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter class_alias_enum_case_typeerror'