| 1 | <?php |
||
| 16 | abstract class Immutable |
||
| 17 | { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Set in parent constructor to resist future attempts to clone or reconstruct |
||
| 21 | * @var bool |
||
| 22 | */ |
||
| 23 | private $constructed; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Immutable constructor. |
||
| 27 | * This must be called from your child class to make the object immutable |
||
| 28 | */ |
||
| 29 | 7 | public function __construct() |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Throw an exception on setting |
||
| 39 | * @param $name |
||
| 40 | * @param $value |
||
| 41 | */ |
||
| 42 | 4 | final public function __set($name, $value) |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Throw an exception on cloning |
||
| 49 | */ |
||
| 50 | 1 | final public function __clone() |
|
| 54 | |||
| 55 | |||
| 56 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.