private function getMethodSource($start, $end) { // Assume blank line after method name // So start one line above if (preg_match('~^\\s*\\{~', $this->source[$start])) { $start--; } $source = array_values($this->source); $result = array_splice($source, $start, $end - $start); Tabs::trim($result); return implode('', $result); }
/** * Close php capturing block and get it wrapped * @return Wrapper */ public static function close() { if (!self::$isOpen) { throw new Exception('Capture is not open, open closing capturing block'); } self::$isOpen = false; $lines = file(self::$currentFile); $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; $fragment = array_slice($lines, self::$currentLine, $trace['line'] - self::$currentLine - 1); Tabs::trim($fragment); return new Wrapper(self::$snippets[self::$currentId] = implode('', $fragment)); }