r97308 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97307‎ | r97308 | r97309 >
Date:18:28, 16 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Refactor variables to give somewhat useful names
Modified paths:
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuery.php
@@ -179,7 +179,7 @@
180180
181181 /**
182182 * Get the array mapping module names to class names
183 - * @return array (modulename => classname)
 183+ * @return array array(modulename => classname)
184184 */
185185 function getModules() {
186186 return array_merge( $this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules );
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -49,61 +49,66 @@
5050 $params = $this->extractRequestParams();
5151 $result = $this->getResult();
5252
53 - $r = array();
 53+ $res = array();
5454 if ( is_array( $params['modules'] ) ) {
55 - $modArr = $this->getMain()->getModules();
56 - $r['modules'] = array();
57 - foreach ( $params['modules'] as $m ) {
58 - if ( !isset( $modArr[$m] ) ) {
59 - $r['modules'][] = array( 'name' => $m, 'missing' => '' );
 55+ $modules = $this->getMain()->getModules();
 56+ $res['modules'] = array();
 57+ foreach ( $params['modules'] as $mod ) {
 58+ if ( !isset( $modules[$mod] ) ) {
 59+ $res['modules'][] = array( 'name' => $mod, 'missing' => '' );
6060 continue;
6161 }
62 - $obj = new $modArr[$m]( $this->getMain(), $m );
63 - $a = $this->getClassInfo( $obj );
64 - $a['name'] = $m;
65 - $r['modules'][] = $a;
 62+ $obj = new $modules[$mod]( $this->getMain(), $mod );
 63+
 64+ $item = $this->getClassInfo( $obj );
 65+ $item['name'] = $mod;
 66+ $res['modules'][] = $item;
6667 }
67 - $result->setIndexedTagName( $r['modules'], 'module' );
 68+ $result->setIndexedTagName( $res['modules'], 'module' );
6869 }
 70+
6971 if ( is_array( $params['querymodules'] ) ) {
70 - $qmodArr = $this->queryObj->getModules();
71 - $r['querymodules'] = array();
 72+ $queryModules = $this->queryObj->getModules();
 73+ $res['querymodules'] = array();
7274 foreach ( $params['querymodules'] as $qm ) {
73 - if ( !isset( $qmodArr[$qm] ) ) {
74 - $r['querymodules'][] = array( 'name' => $qm, 'missing' => '' );
 75+ if ( !isset( $queryModules[$qm] ) ) {
 76+ $res['querymodules'][] = array( 'name' => $qm, 'missing' => '' );
7577 continue;
7678 }
77 - $obj = new $qmodArr[$qm]( $this, $qm );
78 - $a = $this->getClassInfo( $obj );
79 - $a['name'] = $qm;
80 - $a['querytype'] = $this->queryObj->getModuleType( $qm );
81 - $r['querymodules'][] = $a;
 79+ $obj = new $queryModules[$qm]( $this, $qm );
 80+ $item = $this->getClassInfo( $obj );
 81+ $item['name'] = $qm;
 82+ $item['querytype'] = $this->queryObj->getModuleType( $qm );
 83+ $res['querymodules'][] = $item;
8284 }
83 - $result->setIndexedTagName( $r['querymodules'], 'module' );
 85+ $result->setIndexedTagName( $res['querymodules'], 'module' );
8486 }
 87+
8588 if ( $params['mainmodule'] ) {
86 - $r['mainmodule'] = $this->getClassInfo( $this->getMain() );
 89+ $res['mainmodule'] = $this->getClassInfo( $this->getMain() );
8790 }
 91+
8892 if ( $params['pagesetmodule'] ) {
8993 $pageSet = new ApiPageSet( $this->queryObj );
90 - $r['pagesetmodule'] = $this->getClassInfo( $pageSet );
 94+ $res['pagesetmodule'] = $this->getClassInfo( $pageSet );
9195 }
 96+
9297 if ( is_array( $params['formatmodules'] ) ) {
9398 $formats = $this->getMain()->getFormats();
94 - $r['formatmodules'] = array();
 99+ $res['formatmodules'] = array();
95100 foreach ( $params['formatmodules'] as $f ) {
96101 if ( !isset( $formats[$f] ) ) {
97 - $r['formatmodules'][] = array( 'name' => $f, 'missing' => '' );
 102+ $res['formatmodules'][] = array( 'name' => $f, 'missing' => '' );
98103 continue;
99104 }
100105 $obj = new $formats[$f]( $this, $f );
101 - $a = $this->getClassInfo( $obj );
102 - $a['name'] = $f;
103 - $r['formatmodules'][] = $a;
 106+ $item = $this->getClassInfo( $obj );
 107+ $item['name'] = $f;
 108+ $res['formatmodules'][] = $item;
104109 }
105 - $result->setIndexedTagName( $r['formatmodules'], 'module' );
 110+ $result->setIndexedTagName( $res['formatmodules'], 'module' );
106111 }
107 - $result->addValue( null, $this->getModuleName(), $r );
 112+ $result->addValue( null, $this->getModuleName(), $res );
108113 }
109114
110115 /**

Status & tagging log