From d3b7cb742f186547bdd09c26cb98fdd7e2de1f8a Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Mon, 15 Apr 2019 17:07:31 +0100 Subject: [PATCH] tidy: Remove unused var and define $parts var to avoid undefined error Remove unused variable $parent in RemexCompatMunger::comment(). Also, RemexMungerData::dump() could have a possibility that all checks fail and $parts is not defined. There are two ways we can handle this, i.e. either by doing `$parts = []`(setting $parts to an empty array) or by safe guarding using an `isset()` check. This patch uses the former so that $parts is defined and can be used below in the code. Change-Id: I4d601a6fe36a1dce0945686cb9880336d08338be --- includes/tidy/RemexCompatMunger.php | 5 ++--- includes/tidy/RemexMungerData.php | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/tidy/RemexCompatMunger.php b/includes/tidy/RemexCompatMunger.php index 0cc9905823..a37f4f76f0 100644 --- a/includes/tidy/RemexCompatMunger.php +++ b/includes/tidy/RemexCompatMunger.php @@ -482,9 +482,8 @@ class RemexCompatMunger implements TreeHandler { } public function comment( $preposition, $refElement, $text, $sourceStart, $sourceLength ) { - list( $parent, $refNode ) = $this->getParentForInsert( $preposition, $refElement ); - $this->serializer->comment( $preposition, $refNode, $text, - $sourceStart, $sourceLength ); + list( , $refNode ) = $this->getParentForInsert( $preposition, $refElement ); + $this->serializer->comment( $preposition, $refNode, $text, $sourceStart, $sourceLength ); } public function error( $text, $pos ) { diff --git a/includes/tidy/RemexMungerData.php b/includes/tidy/RemexMungerData.php index 08d148f682..c0dd00b5e7 100644 --- a/includes/tidy/RemexMungerData.php +++ b/includes/tidy/RemexMungerData.php @@ -83,6 +83,8 @@ class RemexMungerData { * @return string */ public function dump() { + $parts = []; + if ( $this->childPElement ) { $parts[] = 'childPElement=' . $this->childPElement->getDebugTag(); } -- 2.20.1