Merge "Special:Newpages feed now shows first revision instead of latest revision"
[lhc/web/wiklou.git] / includes / tidy / Balancer.php
index 8da1553..b29a3af 100644 (file)
@@ -1203,7 +1203,7 @@ class BalanceStack implements IteratorAggregate {
                        $furthestBlock = null;
                        $furthestBlockIndex = -1;
                        $stackLength = $this->length();
-                       for ( $i = $index+1; $i < $stackLength; $i++ ) {
+                       for ( $i = $index + 1; $i < $stackLength; $i++ ) {
                                if ( $this->node( $i )->isA( BalanceSets::$specialSet ) ) {
                                        $furthestBlock = $this->node( $i );
                                        $furthestBlockIndex = $i;
@@ -1225,7 +1225,7 @@ class BalanceStack implements IteratorAggregate {
 
                        // Let the common ancestor be the element immediately above
                        // the formatting element in the stack of open elements.
-                       $ancestor = $this->node( $index-1 );
+                       $ancestor = $this->node( $index - 1 );
 
                        // Let a bookmark note the position of the formatting
                        // element in the list of active formatting elements
@@ -1824,7 +1824,7 @@ class Balancer {
         * Regex borrowed from Tim Starling's "remex-html" project.
         */
        const VALID_COMMENT_REGEX = "~ !--
-               (                             # 1. Comment match detector
+               (                           # 1. Comment match detector
                        > | -> | # Invalid short close
                        (                         # 2. Comment contents
                                (?:
@@ -1839,15 +1839,15 @@ class Balancer {
                        (                         # 3. Comment close
                                --> |   # Normal close
                                --!> |  # Comment end bang
-                               (                     # 4. Indicate matches requiring EOF
-                                       --! |   # EOF in comment end bang state
-                                       -- |    # EOF in comment end state
-                                       -  |    # EOF in comment end dash state
-                                               # EOF in comment state
+                               (                       # 4. Indicate matches requiring EOF
+                                       --! |                   # EOF in comment end bang state
+                                       -- |                    # EOF in comment end state
+                                       -  |                    # EOF in comment end dash state
+                                       (?#nothing)             # EOF in comment state
                                )
                        )
                )
-               ([^<]*) \z                    # 5. Non-tag text after the comment
+               ([^<]*) \z                  # 5. Non-tag text after the comment
                ~xs";
 
        /**
@@ -1891,7 +1891,7 @@ class Balancer {
                        $bad = array_uintersect_assoc(
                                $this->allowedHtmlElements,
                                BalanceSets::$unsupportedSet[BalanceSets::HTML_NAMESPACE],
-                               function( $a, $b ) {
+                               function ( $a, $b ) {
                                        // Ignore the values (just intersect the keys) by saying
                                        // all values are equal to each other.
                                        return 0;
@@ -2116,7 +2116,7 @@ class Balancer {
                                return $this->insertToken( $token, $value, $attribs, $selfClose );
                        }
                        // "Any other start tag"
-                       $adjusted = ( $this->fragmentContext && $this->stack->length()===1 ) ?
+                       $adjusted = ( $this->fragmentContext && $this->stack->length() === 1 ) ?
                                $this->fragmentContext : $this->stack->currentNode;
                        $this->stack->insertForeignElement(
                                $adjusted->namespaceURI, $value, $attribs
@@ -2156,7 +2156,7 @@ class Balancer {
                if (
                        $this->allowComments &&
                        !( $this->inRCDATA || $this->inRAWTEXT ) &&
-                       preg_match( Balancer::VALID_COMMENT_REGEX, $x, $regs, PREG_OFFSET_CAPTURE ) &&
+                       preg_match( self::VALID_COMMENT_REGEX, $x, $regs, PREG_OFFSET_CAPTURE ) &&
                        // verify EOF condition where necessary
                        ( $regs[4][1] < 0 || !$this->bitsIterator->valid() )
                ) {
@@ -2242,7 +2242,7 @@ class Balancer {
 
        private function switchMode( $mode ) {
                Assert::parameter(
-                       substr( $mode, -4 )==='Mode', '$mode', 'should end in Mode'
+                       substr( $mode, -4 ) === 'Mode', '$mode', 'should end in Mode'
                );
                $oldMode = $this->parseMode;
                $this->parseMode = $mode;
@@ -2267,8 +2267,8 @@ class Balancer {
                                switch ( $node->localName ) {
                                case 'select':
                                        $stackLength = $this->stack->length();
-                                       for ( $j = $i + 1; $j < $stackLength-1; $j++ ) {
-                                               $ancestor = $this->stack->node( $stackLength-$j-1 );
+                                       for ( $j = $i + 1; $j < $stackLength - 1; $j++ ) {
+                                               $ancestor = $this->stack->node( $stackLength - $j - 1 );
                                                if ( $ancestor->isHtmlNamed( 'template' ) ) {
                                                        break;
                                                }