request->hasSession()) { return; } $ids = [...$this->ownCommentIds(), $commentId]; $this->request->session()->put(self::KEY, array_slice(array_unique($ids), -self::LIMIT)); } /** * @return list */ public function ownCommentIds(): array { if (! $this->request->hasSession()) { return []; } $stored = $this->request->session()->get(self::KEY, []); if (! is_array($stored)) { return []; } return array_values(array_map(intval(...), array_filter($stored, is_numeric(...)))); } }