Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // класс - механизм наследования
- abstract class Inheritance {
- private $_inheritances = array();
- public function __call($method, array $arguments = array()) {
- // тут будем перехватывать вызовы методов
- foreach ($this->_inheritances as $inheritance) {
- $inheritance->invoke($method, $arguments);
- }
- }
- public function invoke($method, $arguments) {
- if (is_callable(array($this, $method))) {
- return call_user_func_array(array($this, $method), $arguments);
- }
- }
- protected function addInheritance(Inheritance $inheritance) {
- $this->_inheritances[get_class($inheritance)] = $inheritance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement