From 8d1660fe6d7fe0701ed0b17e22614d6eb8779ecb Mon Sep 17 00:00:00 2001 From: Khaled Huthaily Date: Sun, 23 Nov 2025 17:36:53 -0700 Subject: [PATCH] Fix PHP 8.5 deprecation - avoid using null as array key This PR is backwards compatible and keeps the public API and behavior the same, but avoids the deprecation warning in PHP 8.5+. --- src/LogFile.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/LogFile.php b/src/LogFile.php index 51e1ae6a..e1ad1642 100644 --- a/src/LogFile.php +++ b/src/LogFile.php @@ -75,11 +75,13 @@ public function type(): LogType public function index(?string $query = null): LogIndex { - if (! isset($this->_logIndexCache[$query])) { - $this->_logIndexCache[$query] = new LogIndex($this, $query); + $cacheKey = $query ?? ''; + + if (! isset($this->_logIndexCache[$cacheKey])) { + $this->_logIndexCache[$cacheKey] = new LogIndex($this, $query); } - return $this->_logIndexCache[$query]; + return $this->_logIndexCache[$cacheKey]; } public function logs(): LogReaderInterface