__setCallable($callable); return; } /** * Get reflection object. * * @param object &$object Object. * @return \ReflectionObject * @throws \Hoa\Praspel\Exception\Preambler */ public function __getReflectionObject(&$object) { static $_out = null; static $_object = null; if (null === $_out) { $callback = $this->__getCallable()->getValidCallback(); if (!is_object($callback[0])) { throw new Praspel\Exception\Preambler( 'Callable %s is not an object.', 0, $this->__getCallable() ); } $_object = $callback[0]; $_out = new \ReflectionObject($_object); } $object = $_object; return $_out; } /** * Set an attribute. * * @param string $name Name. * @param mixed $value Value. * @return \Hoa\Praspel\Preambler\Handler * @throws \Hoa\Praspel\Exception\Preambler */ public function __set($name, $value) { $reflectionObject = $this->__getReflectionObject($object); if (false === $reflectionObject->hasProperty($name)) { throw new Praspel\Exception\Preambler( 'Attribute %s on object %s does not exist, cannot set it.', 1, [$name, $reflectionObject->getName()] ); } $attribute = $reflectionObject->getProperty($name); $attribute->setAccessible(true); $attribute->setValue($object, $value); return $this; } /** * Get an attribute. * * @param string $name Name. * @return mixed * @throws \Hoa\Praspel\Exception\Preambler */ public function __get($name) { $reflectionObject = $this->__getReflectionObject($object); if (false === $reflectionObject->hasProperty($name)) { throw new Praspel\Exception\Preambler( 'Attribute %s on object %s does not exist, cannot get it.', 2, [$name, $reflectionObject->getName()] ); } $attribute = $reflectionObject->getProperty($name); $attribute->setAccessible(true); return $attribute->getValue($object); } /** * Set callable. * * @param \Hoa\Core\Consistency\Xcallable $callable Callable. * @return \Hoa\Core\Consistency\Xcallable */ public function __setCallable(Core\Consistency\Xcallable $callable) { $old = $this->__callable; $this->__callable = $callable; return $old; } /** * Get callable. * * @return \Hoa\Core\Consistency\Xcallable */ public function __getCallable() { return $this->__callable; } }