The use of function sizeof() is forbidden; use count() instead
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 26 Jan 2013 21:20:04 +0000 (22:20 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 26 Jan 2013 21:20:04 +0000 (22:20 +0100)
From phpcs

Change-Id: I919c8af46a722cd1c14bb8c134400e2ec51160d1

includes/MimeMagic.php
includes/SkinLegacy.php
includes/diff/DairikiDiff.php
includes/diff/WikiDiff3.php
includes/json/Services_JSON.php
languages/Language.php

index 65a2a6f..b2611c2 100644 (file)
@@ -330,9 +330,9 @@ class MimeMagic {
                                $this->mMediaTypes[$mtype][] = $mime;
                        }
 
-                       if ( sizeof( $m ) > 1 ) {
+                       if ( count( $m ) > 1 ) {
                                $main = $m[0];
-                               for ( $i=1; $i<sizeof($m); $i += 1 ) {
+                               for ( $i=1; $i<count($m); $i += 1 ) {
                                        $mime = $m[$i];
                                        $this->mMimeTypeAliases[$mime] = $main;
                                }
index 90cd131..8642eca 100644 (file)
@@ -253,7 +253,7 @@ class LegacyTemplate extends BaseTemplate {
                $lang = $title->getPageLanguage();
                $variants = $lang->getVariants();
 
-               if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
+               if ( !$wgDisableLangConversion && count( $variants ) > 1
                        && !$title->isSpecialPage() ) {
                        foreach ( $variants as $code ) {
                                $varname = $lang->getVariantname( $code );
index 6a6f930..eddd9f4 100644 (file)
@@ -43,14 +43,14 @@ class _DiffOp {
         * @return int
         */
        function norig() {
-               return $this->orig ? sizeof( $this->orig ) : 0;
+               return $this->orig ? count( $this->orig ) : 0;
        }
 
        /**
         * @return int
         */
        function nclosing() {
-               return $this->closing ? sizeof( $this->closing ) : 0;
+               return $this->closing ? count( $this->closing ) : 0;
        }
 }
 
@@ -194,8 +194,8 @@ class _DiffEngine {
                $this->_shift_boundaries( $to_lines, $this->ychanged, $this->xchanged );
 
                // Compute the edit operations.
-               $n_from = sizeof( $from_lines );
-               $n_to = sizeof( $to_lines );
+               $n_from = count( $from_lines );
+               $n_to = count( $to_lines );
 
                $edits = array();
                $xi = $yi = 0;
@@ -254,8 +254,8 @@ class _DiffEngine {
                        unset( $wikidiff3 );
                } else {
                        // old diff
-                       $n_from = sizeof( $from_lines );
-                       $n_to = sizeof( $to_lines );
+                       $n_from = count( $from_lines );
+                       $n_to = count( $to_lines );
                        $this->xchanged = $this->ychanged = array();
                        $this->xv = $this->yv = array();
                        $this->xind = $this->yind = array();
@@ -303,7 +303,7 @@ class _DiffEngine {
                        }
 
                        // Find the LCS.
-                       $this->_compareseq( 0, sizeof( $this->xv ), 0, sizeof( $this->yv ) );
+                       $this->_compareseq( 0, count( $this->xv ), 0, count( $this->yv ) );
                }
                wfProfileOut( __METHOD__ );
        }
@@ -533,9 +533,9 @@ class _DiffEngine {
                $i = 0;
                $j = 0;
 
-               assert( 'sizeof($lines) == sizeof($changed)' );
-               $len = sizeof( $lines );
-               $other_len = sizeof( $other_changed );
+               assert( 'count($lines) == count($changed)' );
+               $len = count( $lines );
+               $other_len = count( $other_changed );
 
                while ( 1 ) {
                        /*
@@ -713,7 +713,7 @@ class Diff {
                $lcs = 0;
                foreach ( $this->edits as $edit ) {
                        if ( $edit->type == 'copy' ) {
-                               $lcs += sizeof( $edit->orig );
+                               $lcs += count( $edit->orig );
                        }
                }
                return $lcs;
@@ -732,7 +732,7 @@ class Diff {
 
                foreach ( $this->edits as $edit ) {
                        if ( $edit->orig ) {
-                               array_splice( $lines, sizeof( $lines ), 0, $edit->orig );
+                               array_splice( $lines, count( $lines ), 0, $edit->orig );
                        }
                }
                return $lines;
@@ -751,7 +751,7 @@ class Diff {
 
                foreach ( $this->edits as $edit ) {
                        if ( $edit->closing ) {
-                               array_splice( $lines, sizeof( $lines ), 0, $edit->closing );
+                               array_splice( $lines, count( $lines ), 0, $edit->closing );
                        }
                }
                return $lines;
@@ -829,23 +829,23 @@ class MappedDiff extends Diff {
                $mapped_from_lines, $mapped_to_lines ) {
                wfProfileIn( __METHOD__ );
 
-               assert( 'sizeof( $from_lines ) == sizeof( $mapped_from_lines )' );
-               assert( 'sizeof( $to_lines ) == sizeof( $mapped_to_lines )' );
+               assert( 'count( $from_lines ) == count( $mapped_from_lines )' );
+               assert( 'count( $to_lines ) == count( $mapped_to_lines )' );
 
                parent::__construct( $mapped_from_lines, $mapped_to_lines );
 
                $xi = $yi = 0;
-               for ( $i = 0; $i < sizeof( $this->edits ); $i++ ) {
+               for ( $i = 0; $i < count( $this->edits ); $i++ ) {
                        $orig = &$this->edits[$i]->orig;
                        if ( is_array( $orig ) ) {
-                               $orig = array_slice( $from_lines, $xi, sizeof( $orig ) );
-                               $xi += sizeof( $orig );
+                               $orig = array_slice( $from_lines, $xi, count( $orig ) );
+                               $xi += count( $orig );
                        }
 
                        $closing = &$this->edits[$i]->closing;
                        if ( is_array( $closing ) ) {
-                               $closing = array_slice( $to_lines, $yi, sizeof( $closing ) );
-                               $yi += sizeof( $closing );
+                               $closing = array_slice( $to_lines, $yi, count( $closing ) );
+                               $yi += count( $closing );
                        }
                }
                wfProfileOut( __METHOD__ );
@@ -900,7 +900,7 @@ class DiffFormatter {
                foreach ( $diff->edits as $edit ) {
                        if ( $edit->type == 'copy' ) {
                                if ( is_array( $block ) ) {
-                                       if ( sizeof( $edit->orig ) <= $nlead + $ntrail ) {
+                                       if ( count( $edit->orig ) <= $nlead + $ntrail ) {
                                                $block[] = $edit;
                                        } else {
                                                if ( $ntrail ) {
@@ -916,9 +916,9 @@ class DiffFormatter {
                                $context = $edit->orig;
                        } else {
                                if ( !is_array( $block ) ) {
-                                       $context = array_slice( $context, sizeof( $context ) - $nlead );
-                                       $x0 = $xi - sizeof( $context );
-                                       $y0 = $yi - sizeof( $context );
+                                       $context = array_slice( $context, count( $context ) - $nlead );
+                                       $x0 = $xi - count( $context );
+                                       $y0 = $yi - count( $context );
                                        $block = array();
                                        if ( $context ) {
                                                $block[] = new _DiffOp_Copy( $context );
@@ -928,10 +928,10 @@ class DiffFormatter {
                        }
 
                        if ( $edit->orig ) {
-                               $xi += sizeof( $edit->orig );
+                               $xi += count( $edit->orig );
                        }
                        if ( $edit->closing ) {
-                               $yi += sizeof( $edit->closing );
+                               $yi += count( $edit->closing );
                        }
                }
 
index 6672744..4ce9f19 100644 (file)
@@ -64,7 +64,7 @@ class WikiDiff3 {
 
        public function diff( /*array*/ $from, /*array*/ $to ) {
                // remember initial lengths
-               $m = sizeof( $from );
+               $m = count( $from );
                $n = count( $to );
 
                $this->heuristicUsed = false;
index 2566072..fe84369 100644 (file)
@@ -424,7 +424,7 @@ class Services_JSON
                                */
 
                                // treat as a JSON object
-                               if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
+                               if (is_array($var) && count($var) && (array_keys($var) !== range(0, count($var) - 1))) {
                                        $this->indent++;
                                        $properties = array_map(array($this, 'name_value'),
                                                                array_keys($var),
index 2159052..212ca32 100644 (file)
@@ -3652,7 +3652,7 @@ class Language {
         * @return bool
         */
        public function hasVariants() {
-               return sizeof( $this->getVariants() ) > 1;
+               return count( $this->getVariants() ) > 1;
        }
 
        /**