r88524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88523‎ | r88524 | r88525 >
Date:17:45, 21 May 2011
Author:reedy
Status:ok
Tags:
Comment:
Fixup/add documentation

Remove trailing whitespace
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderContext.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderNoscriptModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderSiteModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserGroupsModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderSiteModule.php
@@ -29,7 +29,9 @@
3030
3131 /**
3232 * Gets list of pages used by this module
33 - *
 33+ *
 34+ * @param $context ResourceLoaderContext
 35+ *
3436 * @return Array: List of pages
3537 */
3638 protected function getPages( ResourceLoaderContext $context ) {
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -569,6 +569,8 @@
570570 * @param $messages Mixed: List of messages associated with this module. May either be an
571571 * associative array mapping message key to value, or a JSON-encoded message blob containing
572572 * the same data, wrapped in an XmlJsCode object.
 573+ *
 574+ * @return string
573575 */
574576 public static function makeLoaderImplementScript( $name, $scripts, $styles, $messages ) {
575577 if ( is_string( $scripts ) ) {
@@ -591,6 +593,8 @@
592594 *
593595 * @param $messages Mixed: Either an associative array mapping message key to value, or a
594596 * JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
 597+ *
 598+ * @return string
595599 */
596600 public static function makeMessageSetScript( $messages ) {
597601 return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) );
@@ -601,6 +605,8 @@
602606 * single stylesheet with @media blocks.
603607 *
604608 * @param $styles Array: List of CSS strings keyed by media type
 609+ *
 610+ * @return string
605611 */
606612 public static function makeCombinedStyles( array $styles ) {
607613 $out = '';
@@ -630,6 +636,11 @@
631637 *
632638 * - ResourceLoader::makeLoaderStateScript( array( $name => $state, ... ) ):
633639 * Set the state of modules with the given names to the given states
 640+ *
 641+ * @param $name string
 642+ * @param $state
 643+ *
 644+ * @return string
634645 */
635646 public static function makeLoaderStateScript( $name, $state = null ) {
636647 if ( is_array( $name ) ) {
@@ -650,6 +661,8 @@
651662 * @param $dependencies Array: List of module names on which this module depends
652663 * @param $group String: Group which the module is in.
653664 * @param $script String: JavaScript code
 665+ *
 666+ * @return string
654667 */
655668 public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $script ) {
656669 $script = str_replace( "\n", "\n\t", trim( $script ) );
@@ -679,6 +692,8 @@
680693 * @param $version Integer: Module version number as a timestamp
681694 * @param $dependencies Array: List of module names on which this module depends
682695 * @param $group String: group which the module is in.
 696+ *
 697+ * @return string
683698 */
684699 public static function makeLoaderRegisterScript( $name, $version = null,
685700 $dependencies = null, $group = null )
@@ -697,6 +712,8 @@
698713 * present.
699714 *
700715 * @param $script String: JavaScript code
 716+ *
 717+ * @return string
701718 */
702719 public static function makeLoaderConditionalScript( $script ) {
703720 $script = str_replace( "\n", "\n\t", trim( $script ) );
@@ -708,11 +725,13 @@
709726 * the given value.
710727 *
711728 * @param $configuration Array: List of configuration values keyed by variable name
 729+ *
 730+ * @return string
712731 */
713732 public static function makeConfigSetScript( array $configuration ) {
714733 return Xml::encodeJsCall( 'mw.config.set', array( $configuration ) );
715734 }
716 -
 735+
717736 /**
718737 * Convert an array of module names to a packed query string.
719738 *
@@ -730,7 +749,7 @@
731750 $suffix = $pos === false ? $module : substr( $module, $pos + 1 );
732751 $groups[$prefix][] = $suffix;
733752 }
734 -
 753+
735754 $arr = array();
736755 foreach ( $groups as $prefix => $suffixes ) {
737756 $p = $prefix === '' ? '' : $prefix . '.';
@@ -739,7 +758,7 @@
740759 $str = implode( '|', $arr );
741760 return str_replace( ".", "!", $str ); # bug 28840
742761 }
743 -
 762+
744763 /**
745764 * Determine whether debug mode was requested
746765 * Order of priority is 1) request param, 2) cookie, 3) $wg setting
@@ -748,8 +767,9 @@
749768 public static function inDebugMode() {
750769 global $wgRequest, $wgResourceLoaderDebug;
751770 static $retval = null;
752 - if ( !is_null( $retval ) )
 771+ if ( !is_null( $retval ) ) {
753772 return $retval;
 773+ }
754774 return $retval = $wgRequest->getFuzzyBool( 'debug',
755775 $wgRequest->getCookie( 'resourceLoaderDebug', '', $wgResourceLoaderDebug ) );
756776 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
@@ -33,6 +33,10 @@
3434
3535 /* Methods */
3636
 37+ /**
 38+ * @param $context ResourceLoaderContext
 39+ * @return array|int|Mixed
 40+ */
3741 public function getModifiedTime( ResourceLoaderContext $context ) {
3842 $hash = $context->getHash();
3943 if ( isset( $this->modifiedTime[$hash] ) ) {
@@ -66,11 +70,19 @@
6771 }
6872 }
6973
 74+ /**
 75+ * @param $context ResourceLoaderContext
 76+ * @return string
 77+ */
7078 public function getScript( ResourceLoaderContext $context ) {
7179 return Xml::encodeJsCall( 'mw.user.options.set',
7280 array( $this->contextUserOptions( $context ) ) );
7381 }
7482
 83+ /**
 84+ * @param $context ResourceLoaderContext
 85+ * @return array
 86+ */
7587 public function getStyles( ResourceLoaderContext $context ) {
7688 global $wgAllowUserCssPrefs;
7789
@@ -111,6 +123,9 @@
112124 return array();
113125 }
114126
 127+ /**
 128+ * @return string
 129+ */
115130 public function getGroup() {
116131 return 'private';
117132 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderContext.php
@@ -99,18 +99,30 @@
100100 return $retval;
101101 }
102102
 103+ /**
 104+ * @return ResourceLoader
 105+ */
103106 public function getResourceLoader() {
104107 return $this->resourceLoader;
105108 }
106 -
 109+
 110+ /**
 111+ * @return WebRequest
 112+ */
107113 public function getRequest() {
108114 return $this->request;
109115 }
110116
 117+ /**
 118+ * @return array
 119+ */
111120 public function getModules() {
112121 return $this->modules;
113122 }
114123
 124+ /**
 125+ * @return string
 126+ */
115127 public function getLanguage() {
116128 if ( $this->language === null ) {
117129 global $wgLang;
@@ -122,6 +134,9 @@
123135 return $this->language;
124136 }
125137
 138+ /**
 139+ * @return string
 140+ */
126141 public function getDirection() {
127142 if ( $this->direction === null ) {
128143 $this->direction = $this->request->getVal( 'dir' );
@@ -133,38 +148,65 @@
134149 return $this->direction;
135150 }
136151
 152+ /**
 153+ * @return string
 154+ */
137155 public function getSkin() {
138156 return $this->skin;
139157 }
140158
 159+ /**
 160+ * @return string
 161+ */
141162 public function getUser() {
142163 return $this->user;
143164 }
144165
 166+ /**
 167+ * @return bool
 168+ */
145169 public function getDebug() {
146170 return $this->debug;
147171 }
148172
 173+ /**
 174+ * @return String
 175+ */
149176 public function getOnly() {
150177 return $this->only;
151178 }
152179
 180+ /**
 181+ * @return String
 182+ */
153183 public function getVersion() {
154184 return $this->version;
155185 }
156186
 187+ /**
 188+ * @return bool
 189+ */
157190 public function shouldIncludeScripts() {
158191 return is_null( $this->only ) || $this->only === 'scripts';
159192 }
160193
 194+ /**
 195+ * @return bool
 196+ */
161197 public function shouldIncludeStyles() {
162198 return is_null( $this->only ) || $this->only === 'styles';
163199 }
164200
 201+ /**
 202+ * @return bool
 203+ */
165204 public function shouldIncludeMessages() {
166205 return is_null( $this->only ) || $this->only === 'messages';
167206 }
168207
 208+ /**
 209+ * @return string
 210+ */
169211 public function getHash() {
170212 if ( !isset( $this->hash ) ) {
171213 $this->hash = implode( '|', array(
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserGroupsModule.php
@@ -26,6 +26,10 @@
2727 /* Protected Methods */
2828 protected $origin = self::ORIGIN_USER_SITEWIDE;
2929
 30+ /**
 31+ * @param $context ResourceLoaderContext
 32+ * @return array
 33+ */
3034 protected function getPages( ResourceLoaderContext $context ) {
3135 if ( $context->getUser() ) {
3236 $user = User::newFromName( $context->getUser() );
@@ -44,9 +48,12 @@
4549 }
4650 return array();
4751 }
48 -
 52+
4953 /* Methods */
50 -
 54+
 55+ /**
 56+ * @return string
 57+ */
5158 public function getGroup() {
5259 return 'user';
5360 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php
@@ -28,6 +28,10 @@
2929 /* Protected Methods */
3030 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
3131
 32+ /**
 33+ * @param $context ResourceLoaderContext
 34+ * @return array
 35+ */
3236 protected function getPages( ResourceLoaderContext $context ) {
3337 if ( $context->getUser() ) {
3438 $username = $context->getUser();
@@ -42,9 +46,12 @@
4347 }
4448 return array();
4549 }
46 -
 50+
4751 /* Methods */
48 -
 52+
 53+ /**
 54+ * @return string
 55+ */
4956 public function getGroup() {
5057 return 'user';
5158 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -292,7 +292,10 @@
293293 public function getGroup() {
294294 return $this->group;
295295 }
296 -
 296+
 297+ /**
 298+ * @return string
 299+ */
297300 public function getPosition() {
298301 return $this->position;
299302 }
@@ -375,10 +378,18 @@
376379
377380 /* Protected Methods */
378381
 382+ /**
 383+ * @param $path string
 384+ * @return string
 385+ */
379386 protected function getLocalPath( $path ) {
380387 return "{$this->localBasePath}/$path";
381388 }
382 -
 389+
 390+ /**
 391+ * @param $path string
 392+ * @return string
 393+ */
383394 protected function getRemotePath( $path ) {
384395 return "{$this->remoteBasePath}/$path";
385396 }
@@ -494,6 +505,9 @@
495506 *
496507 * @param $styles Array: List of media type/list of file paths pairs, to read, remap and
497508 * concetenate
 509+ *
 510+ * @param $flip bool
 511+ *
498512 * @return Array: List of concatenated and remapped CSS data from $styles,
499513 * keyed by media type
500514 */
@@ -521,6 +535,8 @@
522536 * This method can be used as a callback for array_map()
523537 *
524538 * @param $path String: File path of script file to read
 539+ * @param $flip bool
 540+ *
525541 * @return String: CSS data in script file
526542 */
527543 protected function readStyleFile( $path, $flip ) {
Index: trunk/phase3/includes/resourceloader/ResourceLoaderModule.php
@@ -99,7 +99,7 @@
100100 * Set this module's origin. This is called by ResourceLodaer::register()
101101 * when registering the module. Other code should not call this.
102102 *
103 - * @param $name Int origin
 103+ * @param $origin Int origin
104104 */
105105 public function setOrigin( $origin ) {
106106 $this->origin = $origin;
@@ -164,6 +164,8 @@
165165 * Where on the HTML page should this module's JS be loaded?
166166 * 'top': in the <head>
167167 * 'bottom': at the bottom of the <body>
 168+ *
 169+ * @return string
168170 */
169171 public function getPosition() {
170172 return 'bottom';
Index: trunk/phase3/includes/resourceloader/ResourceLoaderNoscriptModule.php
@@ -30,7 +30,9 @@
3131 /**
3232 * Gets list of pages used by this module. Obviously, it makes absolutely no
3333 * sense to include JavaScript files here... :D
34 - *
 34+ *
 35+ * @param $context ResourceLoaderContext
 36+ *
3537 * @return Array: List of pages
3638 */
3739 protected function getPages( ResourceLoaderContext $context ) {
Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -162,6 +162,10 @@
163163
164164 /* Methods */
165165
 166+ /**
 167+ * @param $context ResourceLoaderContext
 168+ * @return string
 169+ */
166170 public function getScript( ResourceLoaderContext $context ) {
167171 global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals;
168172
@@ -211,6 +215,10 @@
212216 return $out;
213217 }
214218
 219+ /**
 220+ * @param $context ResourceLoaderContext
 221+ * @return array|mixed
 222+ */
215223 public function getModifiedTime( ResourceLoaderContext $context ) {
216224 global $IP, $wgCacheEpoch;
217225
@@ -235,9 +243,12 @@
236244 }
237245 return $this->modifiedTime[$hash] = $time;
238246 }
239 -
 247+
240248 /* Methods */
241 -
 249+
 250+ /**
 251+ * @return string
 252+ */
242253 public function getGroup() {
243254 return 'startup';
244255 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -66,6 +66,10 @@
6767
6868 /* Methods */
6969
 70+ /**
 71+ * @param $context ResourceLoaderContext
 72+ * @return string
 73+ */
7074 public function getScript( ResourceLoaderContext $context ) {
7175 $scripts = '';
7276 foreach ( $this->getPages( $context ) as $titleText => $options ) {
@@ -87,6 +91,10 @@
8892 return $scripts;
8993 }
9094
 95+ /**
 96+ * @param $context ResourceLoaderContext
 97+ * @return array
 98+ */
9199 public function getStyles( ResourceLoaderContext $context ) {
92100 global $wgScriptPath;
93101
@@ -119,6 +127,10 @@
120128 return $styles;
121129 }
122130
 131+ /**
 132+ * @param $context ResourceLoaderContext
 133+ * @return int|mixed
 134+ */
123135 public function getModifiedTime( ResourceLoaderContext $context ) {
124136 $modifiedTime = 1; // wfTimestamp() interprets 0 as "now"
125137 $mtimes = $this->getTitleMtimes( $context );
@@ -127,7 +139,11 @@
128140 }
129141 return $modifiedTime;
130142 }
131 -
 143+
 144+ /**
 145+ * @param $context ResourceLoaderContext
 146+ * @return bool
 147+ */
132148 public function isKnownEmpty( ResourceLoaderContext $context ) {
133149 return count( $this->getTitleMtimes( $context ) ) == 0;
134150 }

Status & tagging log