From ebd526f2af3d330ee9a66a8e6620754f3fc60df7 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Mon, 28 Oct 2024 19:31:58 +0100 Subject: [PATCH] Split isset() check for array and property Check the array part first and afterwards the property for null, which does not need the isset() error suppression. Found by a new phan plugin (2efea9f989) This bypass a false positive from phan (T378284) Change-Id: I08651c4b2cd03ecfb38d28ca1cbff599d922208a --- src/ReferenceListFormatter.php | 2 +- src/Validator.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ReferenceListFormatter.php b/src/ReferenceListFormatter.php index 8f92d3d72..bf93c57aa 100644 --- a/src/ReferenceListFormatter.php +++ b/src/ReferenceListFormatter.php @@ -101,7 +101,7 @@ class ReferenceListFormatter { // Make sure the parent is not a subreference. // FIXME: Move to a validation function. $extends =& $ref->extends; - if ( $extends !== null && isset( $groupRefs[$extends]->extends ) ) { + if ( $extends !== null && isset( $groupRefs[$extends] ) && $groupRefs[$extends]->extends !== null ) { $ref->warnings[] = [ 'cite_error_ref_nested_extends', $extends, $groupRefs[$extends]->extends ]; } diff --git a/src/Validator.php b/src/Validator.php index 9764b99a0..868568765 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -66,7 +66,7 @@ class Validator { if ( isset( $groupRefs[$name] ) && $groupRefs[$name]->extends === null ) { // T242141: A top-level can't be changed into a sub-reference return StatusValue::newFatal( 'cite_error_references_duplicate_key', $name ); - } elseif ( isset( $groupRefs[$extends]->extends ) ) { + } elseif ( isset( $groupRefs[$extends] ) && $groupRefs[$extends]->extends !== null ) { // A sub-reference can not be extended a second time (no nesting) return StatusValue::newFatal( 'cite_error_ref_nested_extends', $extends, $groupRefs[$extends]->extends );