/** * @return Code */ public function getCode() { if ($this->code === null) { $this->code = Factory::createCode($this->getReflection()); } return $this->code; }
/** * @param string|object $class * @param \ReflectionClass $reflection * * @throws \RuntimeException */ public function __construct($class, \ReflectionClass $reflection = null) { if (is_string($class)) { if (!class_exists($class)) { throw new \RuntimeException('Class ' . $class . ' is not defined'); } } $this->class = $class; $this->constants = Factory::createConstantCollection(); $this->properties = Factory::createPropertyCollection($class); $this->methods = Factory::createMethodCollection($class); }
/** * @param string $name * * @throws \RuntimeException * * @return boolean */ public function rename($name) { if ($this->getName() == $name) { return true; } if (property_exists($this->getClass(), $name)) { throw new \RuntimeException('Property ' . $name . ' already defined in ' . $this->getClass()); } if (Factory::getExecutor()->renameProperty($this, $name)) { $this->name = $name; return true; } return false; }
/** * @param RunkitFunction $item * * @return bool */ protected function addInternal($item) { return Factory::getExecutor()->addFunction($item->getName(), $item->getArguments(), $item->getCode()); }
/** * @param string $name * * @throws \RuntimeException * * @return boolean */ public function rename($name) { if (defined($name)) { throw new \RuntimeException('Constant with name ' . $name . ' already defined'); } if ($this->getName() == $name) { return true; } if (Factory::getExecutor()->renameConstant($this, $name)) { $this->name = $name; return true; } return false; }
public function testGetExecutor() { $executor = Factory::getExecutor(); $this->assertInstanceOf('Runkit\\Executor', $executor); }
/** * @param Runkit $item * * @return boolean */ protected function removeInternal($item) { return Factory::getExecutor()->removeConstant($item->getName()); }
/** * Remove function from scope * * @return boolean */ public function remove() { $name = $this->getName(); return function_exists($name) ? Factory::getExecutor()->removeFunction($name) : true; }
/** * @param RunkitMethod $item * * @return mixed */ protected function addInternal($item) { return Factory::getExecutor()->addMethod($item); }
/** * @param RunkitProperty $item * * @return mixed */ protected function addInternal($item) { return Factory::getExecutor()->addProperty($item); }
/** * @param string $name * * @throws \RuntimeException * * @return boolean */ public function rename($name) { if (method_exists($this->getClass(), $this->getName())) { if (method_exists($this->getClass(), $name)) { throw new \RuntimeException('Method with name ' . $name . ' already exists in class ' . $this->getClass()); } if (Factory::getExecutor()->renameMethod($this->getClass(), $this->getName(), $name)) { $this->name = $name; return true; } } return false; }