From 43054d1c9650eb469f8d58274eb67fa169789a22 Mon Sep 17 00:00:00 2001 From: IanM Date: Wed, 5 Aug 2026 10:11:41 +0100 Subject: [PATCH] Fix 'using null as an array offset is deprecated' on PHP 8.5 In Line::concat() the two guards test the array before testing the index: if ((isset($mSources[$fi])) && ($fi !== null)) { `isset($mSources[$fi])` evaluates the offset first, so `$fi !== null` is never reached with $fi null and the null check is unreachable. $fi and $ni are null whenever a position has no source file or no name, which is routine, and PHP 8.5 reports each occurrence. Swapping the operands cannot change behaviour, since isset() on a null offset is already false. Verified on 8.5: concat() output is byte-identical before and after, and the test suite passes on 8.1 through 8.5. --- src/parsing/Line.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parsing/Line.php b/src/parsing/Line.php index 135441c..1ac4468 100644 --- a/src/parsing/Line.php +++ b/src/parsing/Line.php @@ -489,10 +489,10 @@ public function concat($line, $dColumn, $mSources, $mNames) $generated->column += $dColumn; $fi = $source->fileIndex; $ni = $source->nameIndex; - if ((isset($mSources[$fi])) && ($fi !== null)) { + if (($fi !== null) && (isset($mSources[$fi]))) { $source->fileIndex = $mSources[$fi]; } - if ((isset($mNames[$ni])) && ($ni !== null)) { + if (($ni !== null) && (isset($mNames[$ni]))) { $source->nameIndex = $mNames[$ni]; } $npos[$generated->column] = $position;