public function apply()
 {
     $runkitFlags = RUNKIT_ACC_PUBLIC;
     if (yTest_Reflection::isStaticProperty($this->className, $this->propertyName)) {
         $setter = 'self::$' . $this->propertyName . ' = $value;';
         $getter = 'return self::$' . $this->propertyName . ';';
         $runkitFlags |= RUNKIT_ACC_STATIC;
     } else {
         $setter = '$this->' . $this->propertyName . ' = $value;';
         $getter = 'return $this->' . $this->propertyName . ';';
     }
     runkit_method_add($this->className, $this->setterName, '$value', $setter, $runkitFlags);
     runkit_method_add($this->className, $this->getterName, '', $getter, $runkitFlags);
 }
Beispiel #2
0
 public function undo()
 {
     yTest_Reflection::restoreMethod($this->className, $this->methodName);
     switch ($this->rewireMode) {
         case self::REWIRE_MODE_FOR_ALL_INSTANCES:
             yTest_CallsRouter::$singleton->onUndoClassMethodRewire($this->className, $this->methodName, $this->delegateObject);
             break;
         case self::REWIRE_MODE_FOR_SPECIFIC_INSTANCE:
             yTest_CallsRouter::$singleton->onUndoInstanceMethodRewire($this->instance, $this->methodName, $this->delegateObject);
             break;
         default:
             yTest_error("invalid rewireMode");
             break;
     }
     //yTest_CallsRouter::instance()->dump();
 }
 public function apply()
 {
     if (method_exists($this->className, yTest_Reflection::getOriginalMethodName($this->methodName))) {
         throw new yTest_Exception('trying to create public delegate (letMeCall) on the already rewired method ' . $this->className . '::' . $this->methodName);
     }
     $params = yTest_Signature::getParamsDecl($this->methodName, $this->className);
     $runkitFlags = RUNKIT_ACC_PUBLIC;
     if (yTest_Reflection::isStaticMethod($this->className, $this->methodName)) {
         $code = 'return self::' . $this->methodName . '(' . yTest_Signature::getArgsForSimpleCall($this->methodName, $this->className) . ');';
         $runkitFlags |= RUNKIT_ACC_STATIC;
     } else {
         $code = 'return $this->' . $this->methodName . '(' . yTest_Signature::getArgsForSimpleCall($this->methodName, $this->className) . ');';
     }
     yTest_debugCC("PARAMS: {$params}", "CODE: {$code}");
     runkit_method_add($this->className, $this->delegateName, $params, $code, $runkitFlags);
 }
 public final function backupStaticProperty($className, $propertyName)
 {
     if (!yTest_Reflection::isStaticProperty($className, $propertyName)) {
         throw yTest_Exception::noSuch("static property", "{$className}::{$propertyName}");
     }
     $isPublic = yTest_Reflection::isPropertyPublic($className, $propertyName);
     if (!$isPublic) {
         $this->letMeAccess($className, $propertyName);
     }
     $change = new yTest_BackupStaticProperty($className, $propertyName, $isPublic);
     $this->codeChanger->enqueue($change);
 }
 public function undo()
 {
     yTest_Reflection::undefineConstant($this->className, $this->constName);
 }
 public function undo()
 {
     yTest_Reflection::restoreFunction($this->functionName);
     //yTest_CallsRouter::instance()->dump();
 }