buffer = $buffer; $this->cursor = $this->normalizeCursor($buffer, $cursor); $this->mode = $mode; $this->readlineInfo = $readlineInfo; } public function getBuffer(): string { return $this->buffer; } public function getCursor(): int { return $this->cursor; } public function getMode(): string { return $this->mode; } /** * Get raw readline callback metadata associated with this request. */ public function getReadlineInfo(): array { return $this->readlineInfo; } private function normalizeCursor(string $buffer, int $cursor): int { $length = \mb_strlen($buffer); return \max(0, \min($cursor, $length)); } }