Brent 3/20/2023

Cloning readonly properties in PHP 8.3

Read Original

This article details the specific new capability in PHP 8.3 that permits the reinitialization of readonly properties during the cloning of an object. It clarifies that this is not a general 'clone with' syntax but is restricted to operations within the magic __clone() method. The primary use case is enabling proper deep cloning of objects with nested readonly properties, preventing unintended reference sharing.

Cloning readonly properties in PHP 8.3

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser