Chris@0: getFunction(); Chris@0: } Chris@0: Chris@0: if ($fileName = $reflector->getFileName()) { Chris@0: if (!is_file($fileName)) { Chris@0: throw new RuntimeException('Source code unavailable.'); Chris@0: } Chris@0: Chris@0: $file = file_get_contents($fileName); Chris@0: $start = $reflector->getStartLine(); Chris@0: $end = $reflector->getEndLine() - $start; Chris@0: Chris@0: $factory = new ConsoleColorFactory($colorMode); Chris@0: $colors = $factory->getConsoleColor(); Chris@0: $highlighter = new Highlighter($colors); Chris@0: Chris@0: return $highlighter->getCodeSnippet($file, $start, 0, $end); Chris@0: } else { Chris@0: throw new RuntimeException('Source code unavailable.'); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Check whether a Reflector instance is reflectable by this formatter. Chris@0: * Chris@0: * @param \Reflector $reflector Chris@0: * Chris@0: * @return bool Chris@0: */ Chris@0: private static function isReflectable(\Reflector $reflector) Chris@0: { Chris@0: return $reflector instanceof \ReflectionClass || Chris@0: $reflector instanceof \ReflectionFunctionAbstract || Chris@0: $reflector instanceof \ReflectionGenerator; Chris@0: } Chris@0: }