Fix indentation whitespace errors
[lhc/web/wiklou.git] / includes / parser / Preprocessor_HipHop.hphp
index d7b0716..8059e35 100644 (file)
@@ -51,7 +51,7 @@ class Preprocessor_HipHop implements Preprocessor {
         * @param $args array
         * @return PPCustomFrame_HipHop
         */
-       function newCustomFrame( array $args ) {
+       function newCustomFrame( $args ) {
                return new PPCustomFrame_HipHop( $this, $args );
        }
 
@@ -109,13 +109,15 @@ class Preprocessor_HipHop implements Preprocessor {
         * @throws MWException
         * @return PPNode_HipHop_Tree
         */
-       function preprocessToObj( string $text, int $flags = 0 ) {
+       function preprocessToObj( $text, $flags = 0 ) {
                wfProfileIn( __METHOD__ );
 
                // Check cache.
                global $wgMemc, $wgPreprocessorCacheThreshold;
 
-               $cacheable = ($wgPreprocessorCacheThreshold !== false && strlen( $text ) > $wgPreprocessorCacheThreshold);
+               $lengthText = strlen( $text );
+
+               $cacheable = ($wgPreprocessorCacheThreshold !== false && $lengthText > $wgPreprocessorCacheThreshold);
                if ( $cacheable ) {
                        wfProfileIn( __METHOD__.'-cacheable' );
 
@@ -239,7 +241,7 @@ class Preprocessor_HipHop implements Preprocessor {
                                        $accum->addLiteral( strval( substr( $text, $i, $literalLength ) ) );
                                        $i += $literalLength;
                                }
-                               if ( $i >= strlen( $text ) ) {
+                               if ( $i >= $lengthText ) {
                                        if ( $currentClosing === "\n" ) {
                                                // Do a past-the-end run to finish off the heading
                                                $curChar = '';
@@ -305,12 +307,12 @@ class Preprocessor_HipHop implements Preprocessor {
                                                // Unclosed comment in input, runs to end
                                                $inner = strval( substr( $text, $i ) );
                                                $accum->addNodeWithText( 'comment', $inner );
-                                               $i = strlen( $text );
+                                               $i = $lengthText;
                                        } else {
                                                $endPos = intval( $variantEndPos );
                                                // Search backwards for leading whitespace
                                                if ( $i ) {
-                                                       $wsStart = $i - intval( strspn( $revText, ' ', strlen( $text ) - $i ) );
+                                                       $wsStart = $i - intval( strspn( $revText, ' ', $lengthText - $i ) );
                                                } else {
                                                        $wsStart = 0;
                                                }
@@ -403,7 +405,7 @@ class Preprocessor_HipHop implements Preprocessor {
                                        } else {
                                                // No end tag -- let it run out to the end of the text.
                                                $inner = strval( substr( $text, $tagEndPos + 1 ) );
-                                               $i = strlen( $text );
+                                               $i = $lengthText;
                                                $haveClose = false;
                                        }
                                }
@@ -468,16 +470,16 @@ class Preprocessor_HipHop implements Preprocessor {
                                $part = $piece->getCurrentPart();
                                // Search back through the input to see if it has a proper close
                                // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient
-                               $wsLength = intval( strspn( $revText, " \t", strlen( $text ) - $i ) );
+                               $wsLength = intval( strspn( $revText, " \t", $lengthText - $i ) );
                                $searchStart = $i - $wsLength;
                                if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) {
                                        // Comment found at line end
                                        // Search for equals signs before the comment
                                        $searchStart = intval( $part->visualEnd );
-                                       $searchStart -= intval( strspn( $revText, " \t", strlen( $text ) - $searchStart ) );
+                                       $searchStart -= intval( strspn( $revText, " \t", $lengthText - $searchStart ) );
                                }
                                $count = intval( $piece->count );
-                               $equalsLength = intval( strspn( $revText, '=', strlen( $text ) - $searchStart ) );
+                               $equalsLength = intval( strspn( $revText, '=', $lengthText - $searchStart ) );
                                $isTreeNode = false;
                                $resultAccum = $accum;
                                if ( $equalsLength > 0 ) {
@@ -1064,11 +1066,12 @@ class PPFrame_HipHop implements PPFrame {
         *
         * @param $args PPNode_HipHop_Array|array|bool
         * @param $title Title|bool
+        * @param $indexOffset A number subtracted from the index attributes of the arguments
         *
         * @throws MWException
         * @return PPTemplateFrame_HipHop
         */
-       function newChild( $args = false, $title = false ) {
+       function newChild( $args = false, $title = false, $indexOffset = 0 ) {
                $namedArgs = array();
                $numberedArgs = array();
                if ( $title === false ) {
@@ -1758,7 +1761,7 @@ class PPNode_HipHop_Tree implements PPNode {
                $children = array();
                for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
                        if ( isset( $child->name ) && $child->name === $name ) {
-                               $children[] = $name;
+                               $children[] = $child;
                        }
                }
                return $children;
@@ -1881,6 +1884,7 @@ class PPNode_HipHop_Tree implements PPNode {
        /**
         * Split a <template> or <tplarg> node
         *
+        * @throws MWException
         * @return array
         */
        function splitTemplate() {