Skip to content

Language: clone() on enum cases throws Error (#3554) - #3570

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-3554-clone-enum-case-error
May 30, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-3554-clone-enum-case-error

Conversation

@PurHur

@PurHur PurHur commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • E::Case enum fetches now materialize a VM EnumCaseEntry (minimal Zend case object) instead of bare scalar constants, preserving backed-enum echo via Variable::toString().
  • TYPE_CLONE detects enum case operands and dispatches a catchable Error with message Cannot clone enum case Class::Case via BuiltinExceptionSupport::materializeError().
  • Registers Throwable as parent of builtin Error so catch (Throwable $e) matches (distinct from readonly-object clone rules in Language: clone() on readonly objects — deep copy + readonly property guards (Zend zend_clones.c parity) #3430).

php-src reference

  • Zend/zend_clones.c — enum clone_obj guard / uncloneable object error
  • Zend/zend_enum.c — case object creation on E::Case fetch

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter clone_enum_case_error test/compliance/VMTest.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/compliance/EnumVMTest.php'

Closes #3554

Made with Cursor

Materialize enum case objects on E::Case fetch and reject clone with
Zend-aligned Error dispatch instead of LogicException. Register Throwable
as Error parent so catch (Throwable) matches.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit c521989 into master May 30, 2026
@PurHur
PurHur deleted the agent/issue-3554-clone-enum-case-error branch June 22, 2026 16:33
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.

Language: clone() on enum unit cases — Error exception (Zend zend_clones.c parity)

1 participant