# that edit() already checked just in case someone tries to sneak
# in the back door with a hand-edited submission URL.
- if ( 'save' == $this->formtype ) {
+ if ( $this->formtype == 'save' ) {
$resultDetails = null;
$status = $this->attemptSave( $resultDetails );
if ( !$this->handleStatus( $status, $resultDetails ) ) {
# First time through: get contents, set time for conflict
# checking, etc.
- if ( 'initial' == $this->formtype || $this->firsttime ) {
+ if ( $this->formtype == 'initial' || $this->firsttime ) {
if ( $this->initialiseForm() === false ) {
$out = $this->context->getOutput();
if ( $out->getRedirect() === '' ) { // mcrundo hack redirects, don't override it
// Put these up at the top to ensure they aren't lost on early form submission
$this->showFormBeforeText();
- if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) {
+ if ( $this->wasDeletedSinceLastEdit() && $this->formtype == 'save' ) {
$username = $this->lastDelete->user_name;
$comment = CommentStore::getStore()
->getComment( 'log_comment', $this->lastDelete )->text;
}
// Add parameter
- if ( false === strpos( $url, '?' ) ) {
+ if ( strpos( $url, '?' ) === false ) {
$url .= '?';
} else {
$url .= '&';
*/
private static function fnamePart( $url ) {
$basename = strrchr( $url, '/' );
- if ( false === $basename ) {
+ if ( $basename === false ) {
$basename = $url;
} else {
$basename = substr( $basename, 1 );
$prefix = $postfix = '';
- if ( 'center' == $frameParams['align'] ) {
+ if ( $frameParams['align'] == 'center' ) {
$prefix = '<div class="center">';
$postfix = '</div>';
$frameParams['align'] = 'none';
$userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
) {
global $wgUser, $wgDisableAnonTalk, $wgLang;
- $talkable = !( $wgDisableAnonTalk && 0 == $userId );
+ $talkable = !( $wgDisableAnonTalk && $userId == 0 );
$blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
$addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
$p = $this->mInterwiki . ':';
}
- if ( 0 != $this->mNamespace ) {
+ if ( $this->mNamespace != 0 ) {
$nsText = $this->getNsText();
if ( $nsText === false ) {
$this->mArticleID = $linkCache->addLinkObj( $this );
$linkCache->forUpdate( $oldUpdate );
} else {
- if ( -1 == $this->mArticleID ) {
+ if ( $this->mArticleID == -1 ) {
$this->mArticleID = $linkCache->addLinkObj( $this );
}
}
if ( $sl < 0 ) {
continue;
}
- if ( '-' == $line[0] && '-' == $line[1] ) {
+ if ( $line[0] == '-' && $line[1] == '-' ) {
continue;
}
$dollarquote = true;
}
} elseif ( !$dollarquote ) {
- if ( ';' == $line[$sl] && ( $sl < 2 || ';' != $line[$sl - 1] ) ) {
+ if ( $line[$sl] == ';' && ( $sl < 2 || $line[$sl - 1] != ';' ) ) {
$done = true;
$line = substr( $line, 0, $sl );
}
call_user_func( $resultCallback, $res, $this );
}
- if ( false === $res ) {
+ if ( $res === false ) {
$err = $this->lastError();
return "Query \"{$cmd}\" failed with error code \"$err\".\n";
* @return string
*/
protected static function flatten( $item ) {
- if ( null === $item ) {
+ if ( $item === null ) {
return '[Null]';
}
$fileQuery['joins']
);
- if ( 0 == $dbr->numRows( $this->historyRes ) ) {
+ if ( $dbr->numRows( $this->historyRes ) == 0 ) {
$this->historyRes = null;
return false;
}
if ( $fi->isNullable() ) {
# # It's NULL - does it need to be NOT NULL?
- if ( 'NOT NULL' === $null ) {
+ if ( $null === 'NOT NULL' ) {
$this->output( "Changing '$table.$field' to not allow NULLs\n" );
if ( $update ) {
$this->db->query( "UPDATE $table SET $field = DEFAULT WHERE $field IS NULL" );
}
} else {
# # It's NOT NULL - does it need to be NULL?
- if ( 'NULL' === $null ) {
+ if ( $null === 'NULL' ) {
$this->output( "Changing '$table.$field' to allow NULLs\n" );
$this->db->query( "ALTER TABLE $table ALTER $field DROP NOT NULL" );
} else {
$fp = fopen( $filename, 'r' );
Wikimedia\restoreWarnings();
- if ( false === $fp ) {
+ if ( $fp === false ) {
throw new RuntimeException( "Could not open \"{$filename}\".\n" );
}
continue;
}
- if ( '-' == $line[0] && '-' == $line[1] ) {
+ if ( $line[0] == '-' && $line[1] == '-' ) {
continue;
}
$resultCallback( $res, $this );
}
- if ( false === $res ) {
+ if ( $res === false ) {
$err = $this->lastError();
return "Query \"{$cmd}\" failed with error code \"$err\".\n";
* @return string[]
*/
private function pg_array_parse( $text, &$output, $limit = false, $offset = 1 ) {
- if ( false === $limit ) {
+ if ( $limit === false ) {
$limit = strlen( $text ) - 1;
$output = [];
}
- if ( '{}' == $text ) {
+ if ( $text == '{}' ) {
return $output;
}
do {
- if ( '{' != $text[$offset] ) {
+ if ( $text[$offset] != '{' ) {
preg_match( "/(\\{?\"([^\"\\\\]|\\\\.)*\"|[^,{}]+)+([,}]+)/",
$text, $match, 0, $offset );
$offset += strlen( $match[0] );
- $output[] = ( '"' != $match[1][0]
+ $output[] = ( $match[1][0] != '"'
? $match[1]
: stripcslashes( substr( $match[1], 1, -1 ) ) );
- if ( '},' == $match[3] ) {
+ if ( $match[3] == '},' ) {
return $output;
}
} else {
$decomp = gzinflate( $serial );
Wikimedia\restoreWarnings();
- if ( false !== $decomp ) {
+ if ( $decomp !== false ) {
$serial = $decomp;
}
}
*/
public function getEmptyPageParserOutput( ParserOptions $options ) {
$this->loadFile();
- if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getId() ) {
+ if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && $this->getId() == 0 ) {
return new ParserOutput();
}
return parent::getEmptyPageParserOutput( $options );
private function openList( $char ) {
$result = $this->closeParagraph();
- if ( '*' === $char ) {
+ if ( $char === '*' ) {
$result .= "<ul><li>";
- } elseif ( '#' === $char ) {
+ } elseif ( $char === '#' ) {
$result .= "<ol><li>";
- } elseif ( ':' === $char ) {
+ } elseif ( $char === ':' ) {
$result .= "<dl><dd>";
- } elseif ( ';' === $char ) {
+ } elseif ( $char === ';' ) {
$result .= "<dl><dt>";
$this->DTopen = true;
} else {
* @return string
*/
private function nextItem( $char ) {
- if ( '*' === $char || '#' === $char ) {
+ if ( $char === '*' || $char === '#' ) {
return "</li>\n<li>";
- } elseif ( ':' === $char || ';' === $char ) {
+ } elseif ( $char === ':' || $char === ';' ) {
$close = "</dd>\n";
if ( $this->DTopen ) {
$close = "</dt>\n";
}
- if ( ';' === $char ) {
+ if ( $char === ';' ) {
$this->DTopen = true;
return $close . '<dt>';
} else {
* @return string
*/
private function closeList( $char ) {
- if ( '*' === $char ) {
+ if ( $char === '*' ) {
$text = "</li></ul>";
- } elseif ( '#' === $char ) {
+ } elseif ( $char === '#' ) {
$text = "</li></ol>";
- } elseif ( ':' === $char ) {
+ } elseif ( $char === ':' ) {
if ( $this->DTopen ) {
$this->DTopen = false;
$text = "</dt></dl>";
$char = $prefix[$commonPrefixLength];
$output .= $this->openList( $char );
- if ( ';' === $char ) {
+ if ( $char === ';' ) {
# @todo FIXME: This is dupe of code above
if ( $this->findColonNoLinks( $t, $term, $t2 ) !== false ) {
$t = $t2;
}
# If we have no prefixes, go to paragraph mode.
- if ( 0 == $prefixLength ) {
+ if ( $prefixLength == 0 ) {
# No prefix (not in list)--go to paragraph mode
# @todo consider using a stack for nestable elements like span, table and div
}
$inBlockElem = !$closeMatch;
} elseif ( !$inBlockElem && !$this->inPre ) {
- if ( ' ' == substr( $t, 0, 1 )
+ if ( substr( $t, 0, 1 ) == ' '
&& ( $this->lastSection === 'pre' || trim( $t ) != '' )
&& !$inBlockquote
) {
# $args is a list of argument nodes, starting from index 0, not including $part1
# @todo FIXME: If piece['parts'] is null then the call to getLength()
# below won't work b/c this $args isn't an object
- $args = ( null == $piece['parts'] ) ? [] : $piece['parts'];
+ $args = ( $piece['parts'] == null ) ? [] : $piece['parts'];
$profileSection = null; // profile templates
$extract = "";
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $lines as $line ) {
- if ( 0 == $contextlines ) {
+ if ( $contextlines == 0 ) {
break;
}
++$lineno;
$fp = fopen( $this->getConfig()->get( 'ReadOnlyFile' ), 'w' );
Wikimedia\restoreWarnings();
- if ( false === $fp ) {
+ if ( $fp === false ) {
# This used to show a file not found error, but the likeliest reason for fopen()
# to fail at this point is insufficient permission to write to the file...good old
# is_writable() is plain wrong in some cases, it seems...
$this->moveOverShared = $request->getBool( 'wpMoveOverSharedFile' );
$this->watch = $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
- if ( 'submit' == $request->getVal( 'action' ) && $request->wasPosted()
+ if ( $request->getVal( 'action' ) == 'submit' && $request->wasPosted()
&& $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
) {
$this->doSubmit();
protected function parseParams( $par ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
foreach ( $bits as $bit ) {
- if ( 'shownav' == $bit ) {
+ if ( $bit === 'shownav' ) {
$this->showNavigation = true;
}
- if ( 'hideliu' === $bit ) {
+ if ( $bit === 'hideliu' ) {
$this->opts->setValue( 'hideliu', true );
}
- if ( 'hidepatrolled' == $bit ) {
+ if ( $bit === 'hidepatrolled' ) {
$this->opts->setValue( 'hidepatrolled', true );
}
- if ( 'hidebots' == $bit ) {
+ if ( $bit === 'hidebots' ) {
$this->opts->setValue( 'hidebots', true );
}
- if ( 'showredirs' == $bit ) {
+ if ( $bit === 'showredirs' ) {
$this->opts->setValue( 'hideredirs', false );
}
if ( is_numeric( $bit ) ) {
&& ( $hidetrans || !$tlRes->numRows() )
&& ( $hideimages || !$ilRes->numRows() )
) {
- if ( 0 == $level ) {
+ if ( $level == 0 ) {
if ( !$this->including() ) {
$out->addHTML( $this->whatlinkshereForm() );
$changed = $this->opts->getChangedValues();
unset( $changed['target'] ); // Already in the request title
- if ( 0 != $prevId ) {
+ if ( $prevId != 0 ) {
$overrides = [ 'from' => $this->opts->getValue( 'back' ) ];
$prev = $this->makeSelfLink( $prev, array_merge( $changed, $overrides ) );
}
- if ( 0 != $nextId ) {
+ if ( $nextId != 0 ) {
$overrides = [ 'from' => $nextId, 'back' => $prevId ];
$next = $this->makeSelfLink( $next, array_merge( $changed, $overrides ) );
}
# Redundant interwiki prefix to the local wiki
foreach ( $this->localInterwikis as $localIW ) {
- if ( 0 == strcasecmp( $parts['interwiki'], $localIW ) ) {
+ if ( strcasecmp( $parts['interwiki'], $localIW ) == 0 ) {
if ( $dbkey == '' ) {
# Empty self-links should point to the Main Page, to ensure
# compatibility with cross-wiki transclusions and the like.
} while ( true );
$fragment = strstr( $dbkey, '#' );
- if ( false !== $fragment ) {
+ if ( $fragment !== false ) {
$parts['fragment'] = str_replace( '_', ' ', substr( $fragment, 1 ) );
$dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) );
# remove whitespace again: prevents "Foo_bar_#"
}
// Any remaining initial :s are illegal.
- if ( $dbkey !== '' && ':' == $dbkey[0] ) {
+ if ( $dbkey !== '' && $dbkey[0] == ':' ) {
throw new MalformedTitleException( 'title-invalid-leading-colon', $text );
}
}
foreach ( $tags as $tag ) {
- if ( false !== strpos( $chunk, $tag ) ) {
+ if ( strpos( $chunk, $tag ) !== false ) {
wfDebug( __METHOD__ . ": found something that may make it be mistaken for html: $tag\n" );
return true;
private function getBlockedStatus( $bFromReplica = true ) {
global $wgProxyWhitelist, $wgUser, $wgApplyIpBlocksToXff, $wgSoftBlockRanges;
- if ( -1 != $this->mBlockedby ) {
+ if ( $this->mBlockedby != -1 ) {
return;
}
*/
public function setCookies( $request = null, $secure = null, $rememberMe = false ) {
$this->load();
- if ( 0 == $this->mId ) {
+ if ( $this->mId == 0 ) {
return;
}
}
$this->load();
- if ( 0 == $this->mId ) {
+ if ( $this->mId == 0 ) {
return; // anon
}
}
# No difference ? Return time unchanged
- if ( 0 == $minDiff ) {
+ if ( $minDiff == 0 ) {
return $ts;
}
$this->fatalError( "invalid username." );
}
- $exists = ( 0 !== $user->idForName() );
+ $exists = ( $user->idForName() !== 0 );
if ( $exists && !$force ) {
$this->fatalError( "Account exists. Perhaps you want the --force option?" );
// For each character with an entry in allkeys.txt, overwrite the implicit
// entry in $this->weights that came from the UCD.
// Also gather a list of tertiary weights, for use in selecting the group header
- while ( false !== ( $line = fgets( $file ) ) ) {
+ while ( ( $line = fgets( $file ) ) !== false ) {
// We're only interested in single-character weights, pick them out with a regex
$line = trim( $line );
if ( !preg_match( '/^([0-9A-F]+)\s*;\s*([^#]*)/', $line, $m ) ) {
$pairs = [];
$lineNum = 0;
- while ( false !== ( $line = fgets( $file ) ) ) {
+ while ( ( $line = fgets( $file ) ) !== false ) {
++$lineNum;
# Strip comments
protected function prune_directory( $dir, $report = false ) {
$tsNow = time();
$dirHandle = opendir( $dir );
- while ( false !== ( $file = readdir( $dirHandle ) ) ) {
+ while ( ( $file = readdir( $dirHandle ) ) !== false ) {
// Skip ".", "..", and also any dirs or files like ".svn" or ".htaccess"
if ( $file[0] != "." ) {
$path = $dir . '/' . $file; // absolute
$rebuilt = false;
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if ( null == $title ) {
+ if ( $title === null ) {
$this->output( "Page {$row->page_id} has bad title\n" );
continue; // broken title?
}
* @return bool
*/
private function compressPage( $row, $extdb ) {
- if ( false !== strpos( $row->old_flags, 'gzip' )
- || false !== strpos( $row->old_flags, 'object' )
+ if ( strpos( $row->old_flags, 'gzip' ) !== false
+ || strpos( $row->old_flags, 'object' ) !== false
) {
# print "Already compressed row {$row->old_id}\n";
return false;
}
private function execute() {
- while ( false !== ( $line = fgets( $this->fh ) ) ) {
+ while ( ( $line = fgets( $this->fh ) ) !== false ) {
$this->lineNum++;
$matches = [];
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = Revision::compressRevisionText( $row->old_text );
- $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
+ $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false,
"Flags should contain 'utf-8'" );
- $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ),
+ $this->assertFalse( strpos( $row->old_flags, 'gzip' ) !== false,
"Flags should not contain 'gzip'" );
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
$row->old_text, "Direct check" );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = Revision::compressRevisionText( $row->old_text );
- $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
+ $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false,
"Flags should contain 'utf-8'" );
- $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ),
+ $this->assertTrue( strpos( $row->old_flags, 'gzip' ) !== false,
"Flags should contain 'gzip'" );
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
gzinflate( $row->old_text ), "Direct check" );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = $store->compressData( $row->old_text );
- $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
+ $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false,
"Flags should contain 'utf-8'" );
- $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ),
+ $this->assertFalse( strpos( $row->old_flags, 'gzip' ) !== false,
"Flags should not contain 'gzip'" );
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
$row->old_text, "Direct check" );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = $store->compressData( $row->old_text );
- $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
+ $this->assertTrue( strpos( $row->old_flags, 'utf-8' ) !== false,
"Flags should contain 'utf-8'" );
- $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ),
+ $this->assertTrue( strpos( $row->old_flags, 'gzip' ) !== false,
"Flags should contain 'gzip'" );
$this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
gzinflate( $row->old_text ), "Direct check" );
$this->hideDeprecated( 'SearchResultSet::next' );
$resultSet->rewind();
$count = 0;
- while ( false !== ( $iterResult = $resultSet->next() ) ) {
+ while ( ( $iterResult = $resultSet->next() ) !== false ) {
$this->assertEquals( $result, $iterResult );
$count++;
}
/** return false if condition begins with 'rc_timestamp ' */
private static function filterOutRcTimestampCondition( $var ) {
- return ( is_array( $var ) || false === strpos( $var, 'rc_timestamp ' ) );
+ return ( is_array( $var ) || strpos( $var, 'rc_timestamp ' ) === false );
}
public function testRcNsFilter() {
# Filter out .txt files
$files = ParserTestRunner::getParserTestFiles();
foreach ( $files as $extName => $parserTestFile ) {
- $isCore = ( 0 === strpos( $parserTestFile, $mwTestDir ) );
+ $isCore = ( strpos( $parserTestFile, $mwTestDir ) === 0 );
if ( $isCore && $wantsCore ) {
self::debug( "included core parser tests: $parserTestFile" );