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); }
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); }