/** * @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|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); }
/** * @param object|string object or class name */ public function __construct($object) { parent::__construct($object, new ReflectionClass($object)); }