- var_dump: documentation ( source)
<?php
trait Immutable {
public function __set($name, $value) {
throw new Exception("can't touch this, nah nah nuh nahhh");
}
public function __get($name) {
return $this->$name;
}
}
class ImmutableThingy {
use Immutable;
protected $foo;
public function __construct($foo)
{
$this->foo = $foo;
}
}
$thing = new ImmutableThingy("bar");
var_dump($thing, $thing->foo);
$thing->foo = 'baz';
var_dump($thing, $thing->foo);