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