ReadOnlyPropertiesTrait
trait ReadOnlyPropertiesTrait
This trait defines magic getters and setters for read-only object's properties
The read-only properties list MUST be declared via the setReadOnlyProperties()
method
of this class (see the documentation of the method for more information).
Keep in mind that the magic methods defined here will ONLY consider read-only
properties (other properties must be handled by the child class).
Methods
Defines the read-only properties names and accessors.
Magic getter for read-only properties.
Magic setter to avoid setting read-only properties.
Magic un-setter to avoid un-setting read-only properties.
Details
at line 54
void
setReadOnlyProperties(
array $data)
Defines the read-only properties names and accessors.
Each key => value
pair of the $data
array must be constructed like:
key
is the name of the property (MUST be defined with protected access in the child class)value
is an accessor for that property: the name of the access method if it exists ortrue
for the default$obj->$key
accessor.
at line 85
mixed
__get(
string $name)
Magic getter for read-only properties.
This will trigger a notice if the property can not be accessed.
at line 109
void
__set(
string $name,
mixed $value)
Magic setter to avoid setting read-only properties.
at line 125
void
__unset(
string $name)
Magic un-setter to avoid un-setting read-only properties.