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
This commit is contained in:
Umherirrender 2024-10-28 19:31:58 +01:00
parent 873bee7e20
commit ebd526f2af
2 changed files with 2 additions and 2 deletions

View file

@ -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 ];
}

View file

@ -66,7 +66,7 @@ class Validator {
if ( isset( $groupRefs[$name] ) && $groupRefs[$name]->extends === null ) {
// T242141: A top-level <ref> 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 );