From a7de863d3aeebee0a7073fb044c567fee8b774a1 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 4 Jul 2014 21:20:22 +0200 Subject: [PATCH] Don't use isset to check for null Change isset() checks for variables that are always defined. Change-Id: Ic96b9661d94742909c0d6b62a8eb2f6a038a774f --- includes/Setup.php | 2 +- includes/SiteConfiguration.php | 8 ++++---- includes/Skin.php | 2 +- includes/Title.php | 14 ++++++++------ includes/User.php | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/includes/Setup.php b/includes/Setup.php index 67d8da3954..fd4465bcf7 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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( diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index b99840fb4b..b7fa6ecfbe 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -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"] ); diff --git a/includes/Skin.php b/includes/Skin.php index 177e2b1df6..14cd7af34f 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -875,7 +875,7 @@ abstract class Skin extends ContextSource { $out = ''; - if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) { + if ( $wgCopyrightIcon ) { $out = $wgCopyrightIcon; } elseif ( $wgRightsIcon ) { $icon = htmlspecialchars( $wgRightsIcon ); diff --git a/includes/Title.php b/includes/Title.php index e038cc71c1..22511b0cab 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; } diff --git a/includes/User.php b/includes/User.php index 67ee7f9482..5a117bdde1 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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 ); -- 2.20.1