Skip to content

Stdlib: class_alias() — enum case alias operand must TypeError not LogicException (basic_functions.c) #6583

Description

@PurHur

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'

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