From 919c471829a0fe3fbd5ff6676985030bcf70f751 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 22 Apr 2014 21:58:25 +0200 Subject: [PATCH] Pass phpcs-strict on maintenance/benchmarks/ Change-Id: I73558930909b35bbc13d0a0ac9368485cb2aa8c4 --- maintenance/benchmarks/bench_HTTP_HTTPS.php | 7 +- .../benchmarks/bench_delete_truncate.php | 1 - maintenance/benchmarks/bench_if_switch.php | 89 +++++++++++-------- .../benchmarks/bench_strtr_str_replace.php | 6 +- .../benchmarks/bench_utf8_title_check.php | 11 +-- .../benchmarks/bench_wfBaseConvert.php | 5 +- maintenance/benchmarks/bench_wfIsWindows.php | 5 +- maintenance/benchmarks/benchmarkHooks.php | 1 - maintenance/benchmarks/benchmarkPurge.php | 1 - 9 files changed, 67 insertions(+), 59 deletions(-) diff --git a/maintenance/benchmarks/bench_HTTP_HTTPS.php b/maintenance/benchmarks/bench_HTTP_HTTPS.php index 6f800fb300..bb7499b738 100644 --- a/maintenance/benchmarks/bench_HTTP_HTTPS.php +++ b/maintenance/benchmarks/bench_HTTP_HTTPS.php @@ -31,8 +31,7 @@ require_once __DIR__ . '/Benchmarker.php'; * * @ingroup Benchmark */ -class bench_HTTP_HTTPS extends Benchmarker { - +class BenchHttpHttps extends Benchmarker { public function __construct() { parent::__construct(); $this->mDescription = "Benchmark HTTP request vs HTTPS request."; @@ -42,7 +41,7 @@ class bench_HTTP_HTTPS extends Benchmarker { $this->bench( array( array( 'function' => array( $this, 'getHTTP' ) ), array( 'function' => array( $this, 'getHTTPS' ) ), - )); + ) ); print $this->getFormattedResults(); } @@ -61,5 +60,5 @@ class bench_HTTP_HTTPS extends Benchmarker { } } -$maintClass = 'bench_HTTP_HTTPS'; +$maintClass = 'BenchHttpHttps'; require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php index ea22b6d068..ed3fe5c1c6 100644 --- a/maintenance/benchmarks/bench_delete_truncate.php +++ b/maintenance/benchmarks/bench_delete_truncate.php @@ -29,7 +29,6 @@ require_once __DIR__ . '/Benchmarker.php'; * @ingroup Benchmark */ class BenchmarkDeleteTruncate extends Benchmarker { - public function __construct() { parent::__construct(); $this->mDescription = "Benchmarks SQL DELETE vs SQL TRUNCATE."; diff --git a/maintenance/benchmarks/bench_if_switch.php b/maintenance/benchmarks/bench_if_switch.php index 80fd9623e9..698a0f0a17 100644 --- a/maintenance/benchmarks/bench_if_switch.php +++ b/maintenance/benchmarks/bench_if_switch.php @@ -31,8 +31,7 @@ require_once __DIR__ . '/Benchmarker.php'; * * @ingroup Maintenance */ -class bench_if_switch extends Benchmarker { - +class BenchIfSwitch extends Benchmarker { public function __construct() { parent::__construct(); $this->mDescription = "Benchmark if elseif... versus switch case."; @@ -42,55 +41,71 @@ class bench_if_switch extends Benchmarker { $this->bench( array( array( 'function' => array( $this, 'doElseIf' ) ), array( 'function' => array( $this, 'doSwitch' ) ), - )); + ) ); print $this->getFormattedResults(); } // bench function 1 function doElseIf() { $a = 'z'; - if( $a == 'a') {} - elseif( $a == 'b') {} - elseif( $a == 'c') {} - elseif( $a == 'd') {} - elseif( $a == 'e') {} - elseif( $a == 'f') {} - elseif( $a == 'g') {} - elseif( $a == 'h') {} - elseif( $a == 'i') {} - elseif( $a == 'j') {} - elseif( $a == 'k') {} - elseif( $a == 'l') {} - elseif( $a == 'm') {} - elseif( $a == 'n') {} - elseif( $a == 'o') {} - elseif( $a == 'p') {} - else {} + if ( $a == 'a' ) { + } elseif ( $a == 'b' ) { + } elseif ( $a == 'c' ) { + } elseif ( $a == 'd' ) { + } elseif ( $a == 'e' ) { + } elseif ( $a == 'f' ) { + } elseif ( $a == 'g' ) { + } elseif ( $a == 'h' ) { + } elseif ( $a == 'i' ) { + } elseif ( $a == 'j' ) { + } elseif ( $a == 'k' ) { + } elseif ( $a == 'l' ) { + } elseif ( $a == 'm' ) { + } elseif ( $a == 'n' ) { + } elseif ( $a == 'o' ) { + } elseif ( $a == 'p' ) { + } else { + } } // bench function 2 function doSwitch() { $a = 'z'; - switch( $a ) { - case 'b': break; - case 'c': break; - case 'd': break; - case 'e': break; - case 'f': break; - case 'g': break; - case 'h': break; - case 'i': break; - case 'j': break; - case 'k': break; - case 'l': break; - case 'm': break; - case 'n': break; - case 'o': break; - case 'p': break; + switch ( $a ) { + case 'b': + break; + case 'c': + break; + case 'd': + break; + case 'e': + break; + case 'f': + break; + case 'g': + break; + case 'h': + break; + case 'i': + break; + case 'j': + break; + case 'k': + break; + case 'l': + break; + case 'm': + break; + case 'n': + break; + case 'o': + break; + case 'p': + break; default: } } } -$maintClass = 'bench_if_switch'; +$maintClass = 'BenchIfSwitch'; require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php b/maintenance/benchmarks/bench_strtr_str_replace.php index 76b5e3ca9c..99e9cfd3ee 100644 --- a/maintenance/benchmarks/bench_strtr_str_replace.php +++ b/maintenance/benchmarks/bench_strtr_str_replace.php @@ -38,8 +38,7 @@ function bfNormalizeTitleStrReplace( $str ) { * * @ingroup Benchmark */ -class bench_strtr_str_replace extends Benchmarker { - +class BenchStrtrStrReplace extends Benchmarker { public function __construct() { parent::__construct(); $this->mDescription = "Benchmark for strtr() vs str_replace()."; @@ -70,8 +69,7 @@ class bench_strtr_str_replace extends Benchmarker { function benchstr_replace_indirect() { bfNormalizeTitleStrReplace( "[[MediaWiki:Some_random_test_page]]" ); } - } -$maintClass = 'bench_strtr_str_replace'; +$maintClass = 'BenchStrtrStrReplace'; require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_utf8_title_check.php b/maintenance/benchmarks/bench_utf8_title_check.php index 078293eb77..1c31256886 100644 --- a/maintenance/benchmarks/bench_utf8_title_check.php +++ b/maintenance/benchmarks/bench_utf8_title_check.php @@ -29,8 +29,7 @@ require_once __DIR__ . '/Benchmarker.php'; * * @ingroup Benchmark */ -class bench_utf8_title_check extends Benchmarker { - +class BenchUtf8TitleCheck extends Benchmarker { private $canRun; private $data; @@ -38,6 +37,7 @@ class bench_utf8_title_check extends Benchmarker { public function __construct() { parent::__construct(); + // @codingStandardsIgnoreStart Ignore long line warnings. $this->data = array( "", "United States of America", // 7bit ASCII @@ -59,11 +59,13 @@ class bench_utf8_title_check extends Benchmarker { . "Sara%20Sidle%7CSofia%20Curtis%7CS%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e%7CWallace%20Langham%7C" . "Warrick%20Brown%7CWendy%20Simms%7C%C3%89tats-Unis" ); + // @codingStandardsIgnoreEnd $this->canRun = function_exists ( 'mb_check_encoding' ); if ( $this->canRun ) { - $this->mDescription = "Benchmark for using a regexp vs. mb_check_encoding to check for UTF-8 encoding."; + $this->mDescription = "Benchmark for using a regexp vs. mb_check_encoding " . + "to check for UTF-8 encoding."; mb_internal_encoding( 'UTF-8' ); } else { $this->mDescription = "CANNOT RUN benchmark using mb_check_encoding: function not available."; @@ -119,8 +121,7 @@ class bench_utf8_title_check extends Benchmarker { function use_mb_check_encoding( $s ) { $this->isutf8 = mb_check_encoding( $s, 'UTF-8' ); } - } -$maintClass = 'bench_utf8_title_check'; +$maintClass = 'BenchUtf8TitleCheck'; require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_wfBaseConvert.php b/maintenance/benchmarks/bench_wfBaseConvert.php index f8a2156206..d08a0b0653 100644 --- a/maintenance/benchmarks/bench_wfBaseConvert.php +++ b/maintenance/benchmarks/bench_wfBaseConvert.php @@ -29,8 +29,7 @@ require_once __DIR__ . '/Benchmarker.php'; * * @ingroup Benchmark */ -class bench_wfBaseConvert extends Benchmarker { - +class BenchWfBaseConvert extends Benchmarker { public function __construct() { parent::__construct(); $this->mDescription = "Benchmark for wfBaseConvert."; @@ -73,5 +72,5 @@ class bench_wfBaseConvert extends Benchmarker { } } -$maintClass = 'bench_wfBaseConvert'; +$maintClass = 'BenchWfBaseConvert'; require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_wfIsWindows.php b/maintenance/benchmarks/bench_wfIsWindows.php index 76cea2cdad..b5cb02584d 100644 --- a/maintenance/benchmarks/bench_wfIsWindows.php +++ b/maintenance/benchmarks/bench_wfIsWindows.php @@ -31,8 +31,7 @@ require_once __DIR__ . '/Benchmarker.php'; * * @ingroup Benchmark */ -class bench_wfIsWindows extends Benchmarker { - +class BenchWfIsWindows extends Benchmarker { public function __construct() { parent::__construct(); $this->mDescription = "Benchmark for wfIsWindows."; @@ -65,5 +64,5 @@ class bench_wfIsWindows extends Benchmarker { } } -$maintClass = 'bench_wfIsWindows'; +$maintClass = 'BenchWfIsWindows'; require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php index 59d3bdf77b..bb7af2b9d5 100644 --- a/maintenance/benchmarks/benchmarkHooks.php +++ b/maintenance/benchmarks/benchmarkHooks.php @@ -29,7 +29,6 @@ require_once __DIR__ . '/Benchmarker.php'; * @ingroup Benchmark */ class BenchmarkHooks extends Benchmarker { - public function __construct() { parent::__construct(); $this->mDescription = 'Benchmark MediaWiki Hooks.'; diff --git a/maintenance/benchmarks/benchmarkPurge.php b/maintenance/benchmarks/benchmarkPurge.php index 17973582d8..dcaacab6f2 100644 --- a/maintenance/benchmarks/benchmarkPurge.php +++ b/maintenance/benchmarks/benchmarkPurge.php @@ -29,7 +29,6 @@ require_once __DIR__ . '/Benchmarker.php'; * @ingroup Benchmark */ class BenchmarkPurge extends Benchmarker { - public function __construct() { parent::__construct(); $this->mDescription = "Benchmark the Squid purge functions."; -- 2.20.1