예제 #1
0
파일: ModelA.php 프로젝트: bogdananton/vsc
 /**
  * @param string $sIncName
  * @return mixed
  */
 public function __get($sIncName)
 {
     try {
         $oProperty = new \ReflectionProperty($this, $sIncName);
         if (!$oProperty->isPublic()) {
             // try for a getter method
             $sGetterName = 'get' . ucfirst($sIncName);
             $oGetter = new \ReflectionMethod($this, $sGetterName);
             $this->_current = $sIncName;
             // ?? I wonder if setting the offset to the current read position is the right way
             return $oGetter->invoke($this, $sIncName);
         } else {
             $this->_current = $sIncName;
             // ?? I wonder if setting the offset to the current read position is the right way
             return $oProperty->getValue($this);
         }
     } catch (\ReflectionException $e) {
         // reflection issue
         return parent::__get($sIncName);
     }
 }
예제 #2
0
 public function test__get()
 {
     $null = new Base();
     $this->assertInstanceOf(Base::class, $null->__get('test'));
     $this->assertInstanceOf(Base::class, $null->test);
 }