Пример #1
0
 /**
  * @param string $name
  * @param mixed $value
  * @throws \Kdyby\Autowired\MemberAccessException
  * @return mixed
  */
 public function __set($name, $value)
 {
     if (!isset($this->autowireProperties[$name])) {
         return parent::__set($name, $value);
     } elseif ($this->autowireProperties[$name]['value']) {
         throw new \Kdyby\Autowired\MemberAccessException("Property \${$name} has already been set.");
     } elseif (!$value instanceof $this->autowireProperties[$name]['type']) {
         throw new \Kdyby\Autowired\MemberAccessException("Property \${$name} must be an instance of " . $this->autowireProperties[$name]['type'] . ".");
     }
     return $this->autowireProperties[$name]['value'] = $value;
 }