/** * @param object|string object or class name * @param string method name */ public function __construct($object, $method) { parent::__construct($object, new ReflectionMethod($object, $method)); $ac = PHP_VERSION_ID < 50302 ? 'AccessAccessorPhp52' : 'AccessAccessor'; $accessor = new $ac(); $this->access = $accessor->accessMethod($this->reflection); }
/** * @param object|NULL * @return AccessClass $this */ public function asInstance($object) { parent::asInstance($object); foreach ($this->methods as $a) { $a->asInstance($this->instance); } foreach ($this->properties as $a) { $a->asInstance($this->instance); } return $this; }
/** * @param object|string object or class name * @param string property name */ public function __construct($object, $property) { try { $r = new ReflectionProperty($object, $property); } catch (ReflectionException $e) { $class = $object; while ($class = get_parent_class($class)) { try { $r = new ReflectionProperty($class, $property); break; } catch (ReflectionException $ee) { } } if (!isset($r)) { throw $e; } } parent::__construct($object, $r); $ac = PHP_VERSION_ID < 50300 ? 'AccessAccessorPhp52' : 'AccessAccessor'; $accessor = new $ac(); $this->access = $accessor->accessProperty($this->reflection); }