getMessages(); $path = $result->getPath(); $data = explode("\n", $result->getData()); array_unshift($data, ''); // make the line numbers work as array indices foreach ($messages as $message) { $dictionary = $message->toDictionary(); $dictionary['context'] = implode("\n", array_slice( $data, max(1, $message->getLine() - self::LINES_OF_CONTEXT), self::LINES_OF_CONTEXT * 2 + 1)); $dictionary['path'] = $path; $this->writeOut(json_encode(array_filter($dictionary, 'remove_null'))."\n"); } } }