Brent 8/3/2025

Readonly or private(set)

Read Original

This technical article compares PHP's readonly properties (introduced in PHP 8.1) with private(set) asymmetric visibility (from PHP 8.4). It explains how readonly ensures a property is set only once, while private(set) allows public reading but restricts writing to within the class. The author discusses the practical implications for creating structured, typed data objects and reducing boilerplate code.

Readonly or private(set)

Comments

No comments yet

Be the first to share your thoughts!