Don't use isset to check for null

Change isset() checks for variables that are always defined.

Change-Id: Ic96b9661d94742909c0d6b62a8eb2f6a038a774f
This commit is contained in:
Alexandre Emsenhuber 2014-07-04 21:20:22 +02:00
parent fab8c6f541
commit a7de863d3a
5 changed files with 15 additions and 13 deletions

View file

@ -114,7 +114,7 @@ if ( isset( $wgFooterIcons['copyright'] )
&& isset( $wgFooterIcons['copyright']['copyright'] )
&& $wgFooterIcons['copyright']['copyright'] === array()
) {
if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
if ( $wgCopyrightIcon ) {
$wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
} elseif ( $wgRightsIcon || $wgRightsText ) {
$wgFooterIcons['copyright']['copyright'] = array(

View file

@ -207,14 +207,14 @@ class SiteConfiguration {
// Do tag settings
foreach ( $params['tags'] as $tag ) {
if ( array_key_exists( $tag, $thisSetting ) ) {
if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
if ( is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting[$tag] );
} else {
$retval = $thisSetting[$tag];
}
break 2;
} elseif ( array_key_exists( "+$tag", $thisSetting ) && is_array( $thisSetting["+$tag"] ) ) {
if ( !isset( $retval ) ) {
if ( $retval === null ) {
$retval = array();
}
$retval = self::arrayMerge( $retval, $thisSetting["+$tag"] );
@ -224,7 +224,7 @@ class SiteConfiguration {
$suffix = $params['suffix'];
if ( !is_null( $suffix ) ) {
if ( array_key_exists( $suffix, $thisSetting ) ) {
if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) {
if ( is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting[$suffix] );
} else {
$retval = $thisSetting[$suffix];
@ -233,7 +233,7 @@ class SiteConfiguration {
} elseif ( array_key_exists( "+$suffix", $thisSetting )
&& is_array( $thisSetting["+$suffix"] )
) {
if ( !isset( $retval ) ) {
if ( $retval === null ) {
$retval = array();
}
$retval = self::arrayMerge( $retval, $thisSetting["+$suffix"] );

View file

@ -875,7 +875,7 @@ abstract class Skin extends ContextSource {
$out = '';
if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
if ( $wgCopyrightIcon ) {
$out = $wgCopyrightIcon;
} elseif ( $wgRightsIcon ) {
$icon = htmlspecialchars( $wgRightsIcon );

View file

@ -2569,7 +2569,7 @@ class Title {
return false;
}
if ( !isset( $this->mTitleProtection ) ) {
if ( $this->mTitleProtection === null ) {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
'protected_titles',
@ -2722,7 +2722,7 @@ class Title {
* @since 1.23
*/
public function areCascadeProtectionSourcesLoaded( $getPages = true ) {
return $getPages ? isset( $this->mCascadeSources ) : isset( $this->mHasCascadingRestrictions );
return $getPages ? $this->mCascadeSources !== null : $this->mHasCascadingRestrictions !== null;
}
/**
@ -2742,9 +2742,9 @@ class Title {
global $wgContLang;
$pagerestrictions = array();
if ( isset( $this->mCascadeSources ) && $getPages ) {
if ( $this->mCascadeSources !== null && $getPages ) {
return array( $this->mCascadeSources, $this->mCascadingRestrictions );
} elseif ( isset( $this->mHasCascadingRestrictions ) && !$getPages ) {
} elseif ( $this->mHasCascadingRestrictions !== null && !$getPages ) {
return array( $this->mHasCascadingRestrictions, $pagerestrictions );
}
@ -3090,7 +3090,7 @@ class Title {
# alone to cache the result. There's no point in having it hanging
# around uninitialized in every Title object; therefore we only add it
# if needed and don't declare it statically.
if ( !isset( $this->mHasSubpages ) ) {
if ( $this->mHasSubpages === null ) {
$this->mHasSubpages = false;
$subpages = $this->getSubpages( 1 );
if ( $subpages instanceof TitleArray ) {
@ -4779,7 +4779,9 @@ class Title {
* @return string Last-touched timestamp
*/
public function getTouched( $db = null ) {
$db = isset( $db ) ? $db : wfGetDB( DB_SLAVE );
if ( $db === null ) {
$db = wfGetDB( DB_SLAVE );
}
$touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
return $touched;
}

View file

@ -2946,7 +2946,7 @@ class User implements IDBAccessObject {
return null;
}
if ( !isset( $this->mEditCount ) ) {
if ( $this->mEditCount === null ) {
/* Populate the count, if it has not been populated yet */
wfProfileIn( __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );