コード例 #1
0
ファイル: Method.php プロジェクト: petrp/access
 /**
  * @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);
 }
コード例 #2
0
ファイル: Class.php プロジェクト: petrp/access
 /**
  * @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;
 }
コード例 #3
0
ファイル: Property.php プロジェクト: petrp/access
 /**
  * @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);
 }