From 25bc3a0727ce31efb1c07a67b89a70ff3eef494a Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 26 Jan 2013 22:20:04 +0100 Subject: [PATCH] The use of function sizeof() is forbidden; use count() instead From phpcs Change-Id: I919c8af46a722cd1c14bb8c134400e2ec51160d1 --- includes/MimeMagic.php | 4 +-- includes/SkinLegacy.php | 2 +- includes/diff/DairikiDiff.php | 52 ++++++++++++++++----------------- includes/diff/WikiDiff3.php | 2 +- includes/json/Services_JSON.php | 2 +- languages/Language.php | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 65a2a6fa79..b2611c2e00 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -330,9 +330,9 @@ class MimeMagic { $this->mMediaTypes[$mtype][] = $mime; } - if ( sizeof( $m ) > 1 ) { + if ( count( $m ) > 1 ) { $main = $m[0]; - for ( $i=1; $imMimeTypeAliases[$mime] = $main; } diff --git a/includes/SkinLegacy.php b/includes/SkinLegacy.php index 90cd131982..8642eca6f4 100644 --- a/includes/SkinLegacy.php +++ b/includes/SkinLegacy.php @@ -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 ); diff --git a/includes/diff/DairikiDiff.php b/includes/diff/DairikiDiff.php index 6a6f930a2c..eddd9f4f0b 100644 --- a/includes/diff/DairikiDiff.php +++ b/includes/diff/DairikiDiff.php @@ -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 ); } } diff --git a/includes/diff/WikiDiff3.php b/includes/diff/WikiDiff3.php index 667274456d..4ce9f19055 100644 --- a/includes/diff/WikiDiff3.php +++ b/includes/diff/WikiDiff3.php @@ -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; diff --git a/includes/json/Services_JSON.php b/includes/json/Services_JSON.php index 2566072dba..fe84369aac 100644 --- a/includes/json/Services_JSON.php +++ b/includes/json/Services_JSON.php @@ -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), diff --git a/languages/Language.php b/languages/Language.php index 21590524e3..212ca323e8 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -3652,7 +3652,7 @@ class Language { * @return bool */ public function hasVariants() { - return sizeof( $this->getVariants() ) > 1; + return count( $this->getVariants() ) > 1; } /** -- 2.20.1