Class Wither Method¶
With is a prefix, that tells the reader that the getter returns a copy of the object, and not the object itself.
<?php
class x {
private A $property;
// getter
public function getProperty() : A {
return $this->property;
}
// wither
public function withProperty() : A{
return clone $this->property;
}
}
?>
See also RFC: Accessors
Related : Class, Class Setter Method, Class Getter Method, Immutable