예제 #1
0
 public function test__setDev()
 {
     $null = new Base();
     $env = new vsc_underTest___toString();
     $env->setIsDevelopment(true);
     vsc::setInstance($env);
     try {
         $null->__set(uniqid('test'), uniqid('val:'));
     } catch (\Exception $e) {
         $this->assertInstanceOf(ExceptionUnimplemented::class, $e);
         $this->assertInstanceOf(Exception::class, $e);
     }
     try {
         $null->test = uniqid('val:');
     } catch (\Exception $e) {
         $this->assertInstanceOf(ExceptionUnimplemented::class, $e);
         $this->assertInstanceOf(Exception::class, $e);
     }
 }
예제 #2
0
파일: ModelA.php 프로젝트: bogdananton/vsc
 /**
  * @param string $sIncName
  * @param mixed $value
  * @throws ExceptionUnimplemented
  * @throws \ReflectionException
  */
 public function __set($sIncName, $value)
 {
     if (is_null($sIncName)) {
         throw new \ReflectionException('Can\'t set a value to a null property on the current object [' . get_class($this) . ']');
     }
     try {
         $oProperty = new \ReflectionProperty($this, $sIncName);
         if (!$oProperty->isPublic()) {
             // trying for a setter
             $sSetterName = 'set' . ucfirst($sIncName);
             $oSetter = new \ReflectionMethod($this, $sSetterName);
             $oSetter->invoke($this, $value);
         } else {
             $oProperty->setValue($this, $value);
         }
         $this->_current = $sIncName;
         return;
     } catch (\ReflectionException $e) {
         //			$this->_current = $sIncName;
         //			$this->$sIncName = $value;
     }
     parent::__set($sIncName, $value);
 }