MDL-39846 add more magic and improve tests

This commit is contained in:
Petr Škoda
2013-07-19 08:43:28 +02:00
parent 05a970d3be
commit 605a8c336f
2 changed files with 72 additions and 4 deletions
+25 -3
View File
@@ -520,9 +520,6 @@ abstract class base {
/**
* Magic getter for read only access.
*
* Note: we must not allow modification of data from outside,
* after trigger() the data MUST NOT CHANGE!!!
*
* @param string $name
* @return mixed
*/
@@ -533,4 +530,29 @@ abstract class base {
debugging("Accessing non-existent event property '$name'");
}
/**
* Magic setter.
*
* Note: we must not allow modification of data from outside,
* after trigger() the data MUST NOT CHANGE!!!
*
* @param string $name
* @param mixed $value
*
* @throws \coding_exception
*/
public function __set($name, $value) {
throw new \coding_exception('Event properties must not be modified.');
}
/**
* Is data property set?
*
* @param string $name
* @return bool
*/
public function __isset($name) {
return isset($this->data[$name]);
}
}