tidy: Remove unused var and define $parts var to avoid undefined error
authorDerick Alangi <alangiderick@gmail.com>
Mon, 15 Apr 2019 16:07:31 +0000 (17:07 +0100)
committerDerick Alangi <alangiderick@gmail.com>
Mon, 10 Jun 2019 13:34:54 +0000 (14:34 +0100)
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
includes/tidy/RemexMungerData.php

index 0cc9905..a37f4f7 100644 (file)
@@ -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 ) {
index 08d148f..c0dd00b 100644 (file)
@@ -83,6 +83,8 @@ class RemexMungerData {
         * @return string
         */
        public function dump() {
+               $parts = [];
+
                if ( $this->childPElement ) {
                        $parts[] = 'childPElement=' . $this->childPElement->getDebugTag();
                }