/** * Creates a reflection instance. * * @param \ReflectionClass $internalReflection Internal reflection instance * @param \TokenReflection\Broker $broker Reflection broker instance * * @return \TokenReflection\Php\ReflectionFunction * @throws \TokenReflection\Exception\RuntimeException If an invalid internal reflection object was provided. */ public static function create(Reflector $internalReflection, Broker $broker) { if (!$internalReflection instanceof InternalReflectionFunction) { throw new Exception\RuntimeException('Invalid reflection instance provided, ReflectionFunction expected.', Exception\RuntimeException::INVALID_ARGUMENT); } return $broker->getFunction($internalReflection->getName()); }
/** * Exports a reflected object. * * @param \TokenReflection\Broker $broker Broker instance * @param string $function Function name * @param boolean $return Return the export instead of outputting it * * @return string|null * @throws \TokenReflection\Exception\RuntimeException If requested parameter doesn't exist. */ public static function export(Broker $broker, $function, $return = false) { $functionName = $function; $function = $broker->getFunction($functionName); if (null === $function) { throw new Exception\RuntimeException(sprintf('Function %s() does not exist.', $functionName), Exception\RuntimeException::DOES_NOT_EXIST); } if ($return) { return $function->__toString(); } echo $function->__toString(); }