r91657 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91656‎ | r91657 | r91658 >
Date:17:42, 7 July 2011
Author:ialex
Status:ok
Tags:
Comment:
* Don't use isset() to check only for null
* Also pass the Title object in RequestContext::msg()
Modified paths:
  • /trunk/phase3/includes/RequestContext.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RequestContext.php
@@ -78,7 +78,7 @@
7979 * @return Title
8080 */
8181 public function getTitle() {
82 - if ( !isset($this->title) ) {
 82+ if ( $this->title === null ) {
8383 global $wgTitle; # fallback to $wg till we can improve this
8484 $this->title = $wgTitle;
8585 }
@@ -98,7 +98,7 @@
9999 * @return OutputPage object
100100 */
101101 public function getOutput() {
102 - if ( !isset( $this->output ) ) {
 102+ if ( $this->output === null ) {
103103 $this->output = new OutputPage( $this );
104104 }
105105 return $this->output;
@@ -119,7 +119,7 @@
120120 * @return User
121121 */
122122 public function getUser() {
123 - if ( !isset($this->user) ) {
 123+ if ( $this->user === null ) {
124124 $this->user = User::newFromSession( $this->getRequest() );
125125 }
126126 return $this->user;
@@ -131,7 +131,7 @@
132132 * @return Language
133133 */
134134 public function getLang() {
135 - if ( !isset($this->lang) ) {
 135+ if ( $this->lang === null ) {
136136 global $wgLanguageCode, $wgContLang;
137137 $code = $this->getRequest()->getVal(
138138 'uselang',
@@ -164,7 +164,7 @@
165165 * @return Skin
166166 */
167167 public function getSkin() {
168 - if ( !isset($this->skin) ) {
 168+ if ( $this->skin === null ) {
169169 wfProfileIn( __METHOD__ . '-createskin' );
170170
171171 global $wgHiddenPrefs;
@@ -195,7 +195,7 @@
196196 */
197197 public function msg() {
198198 $args = func_get_args();
199 - return call_user_func_array( 'wfMessage', $args )->inLanguage( $this->getLang() );
 199+ return call_user_func_array( 'wfMessage', $args )->inLanguage( $this->getLang() )->title( $this->getTitle() );
200200 }
201201
202202 /** Static methods **/
@@ -207,7 +207,7 @@
208208 */
209209 public static function getMain() {
210210 static $instance = null;
211 - if ( !isset($instance) ) {
 211+ if ( $instance === null ) {
212212 $instance = new self;
213213 }
214214 return $instance;

Follow-up revisions

RevisionCommit summaryAuthorDate
r91715Follow-up r91657: missed this oneialex07:02, 8 July 2011

Status & tagging log