Also removed some unnecessary ones. I think I've caught them all.
The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.
Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
wfHttpError(
400,
'Bad Request',
- "unknown function " . (string) $this->func_name
+ "unknown function " . $this->func_name
);
} elseif ( !User::isEveryoneAllowed( 'read' ) && !$wgUser->isAllowed( 'read' ) ) {
wfHttpError(
$sourceBase > 36 ||
$destBase < 2 ||
$destBase > 36 ||
- $sourceBase != (int) $sourceBase ||
- $destBase != (int) $destBase ||
- $pad != (int) $pad ||
+ $sourceBase != (int)$sourceBase ||
+ $destBase != (int)$destBase ||
+ $pad != (int)$pad ||
!preg_match( "/^[" . substr( '0123456789abcdefghijklmnopqrstuvwxyz', 0, $sourceBase ) . "]+$/i", $input )
) {
return false;
$work += $digit;
if ( $workDigits || $work >= $destBase ) {
- $workDigits[] = (int) ( $work / $destBase );
+ $workDigits[] = (int)( $work / $destBase );
}
$work %= $destBase;
}
# * text/xml
# * application/xml
# * Any mimetype with a subtype ending in +xml (this implicitly includes application/xhtml+xml)
- return (bool) preg_match( '!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
+ return (bool)preg_match( '!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype );
}
/**
$n += pow( 2, 32 );
# On 32-bit platforms (and on Windows), 2^32 does not fit into an int,
# so $n becomes a float. We convert it to string instead.
- if ( is_float ( $n ) ) {
- $n = (string) $n;
+ if ( is_float( $n ) ) {
+ $n = (string)$n;
}
}
}
* @since 1.20
*/
public function setInterfaceMessageFlag( $value ) {
- $this->interface = (bool) $value;
+ $this->interface = (bool)$value;
return $this;
}
* @return Message: $this
*/
public function useDatabase( $value ) {
- $this->useDatabase = (bool) $value;
+ $this->useDatabase = (bool)$value;
return $this;
}
$popts = $this->parserOptions();
$oldTidy = $popts->setTidy( $tidy );
- $popts->setInterfaceMessage( (bool) $interface );
+ $popts->setInterfaceMessage( (bool)$interface );
$parserOutput = $wgParser->parse(
$text, $title, $popts,
protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array(), $loadCall = false ) {
global $wgResourceLoaderUseESI;
- $modules = (array) $modules;
+ $modules = (array)$modules;
if ( !count( $modules ) ) {
return '';
* @param $limit Int|String
*/
function setLimit( $limit ) {
- $limit = (int) $limit;
+ $limit = (int)$limit;
// WebRequest::getLimitOffset() puts a cap of 5000, so do same here.
if ( $limit > 5000 ) {
$limit = 5000;
$ # End of string
/ix"; // case Insensitive, eXtended
- return (bool) preg_match( $HTML5_email_regexp, $addr );
+ return (bool)preg_match( $HTML5_email_regexp, $addr );
}
}
if ( count( $data ) >= 2 ) {
// Combination hours and minutes.
$diff = abs( (int)$data[0] ) * 60 + (int)$data[1];
- if ( (int) $data[0] < 0 ) {
+ if ( (int)$data[0] < 0 ) {
$diff *= -1;
}
} else {
$data = explode( ' ', fgets( $handle ) ); // "<clk seq> <sec> <msec> <counter> <offset>"
$clockChanged = false; // clock set back significantly?
if ( count( $data ) == 5 ) { // last UID info already initialized
- $clkSeq = (int) $data[0] % $clockSeqSize;
- $prevTime = array( (int) $data[1], (int) $data[2] );
- $offset = (int) $data[4] % $counterSize; // random counter offset
+ $clkSeq = (int)$data[0] % $clockSeqSize;
+ $prevTime = array( (int)$data[1], (int)$data[2] );
+ $offset = (int)$data[4] % $counterSize; // random counter offset
$counter = 0; // counter for UIDs with the same timestamp
// Delay until the clock reaches the time of the last ID.
// This detects any microtime() drift among processes.
$time = self::millitime();
} elseif ( $time == $prevTime ) {
// Bump the counter if there are timestamp collisions
- $counter = (int) $data[3] % $counterSize;
+ $counter = (int)$data[3] % $counterSize;
if ( ++$counter >= $counterSize ) { // sanity (starts at 0)
flock( $handle, LOCK_UN ); // abort
throw new MWException( "Counter overflow for timestamp value." );
*/
protected static function millitime() {
list( $msec, $sec ) = explode( ' ', microtime() );
- return array( (int) $sec, (int) ( $msec * 1000 ) );
+ return array( (int)$sec, (int)( $msec * 1000 ) );
}
function __destruct() {
$this->mEditCount = $count;
wfProfileOut( __METHOD__ );
}
- return (int) $this->mEditCount;
+ return (int)$this->mEditCount;
}
/**
// Pull from a slave to be less cruel to servers
// Accuracy isn't the point anyway here
$dbr = wfGetDB( DB_SLAVE );
- $count = (int) $dbr->selectField(
+ $count = (int)$dbr->selectField(
'revision',
'COUNT(rev_user)',
array( 'rev_user' => $this->getId() ),
if ( !$wgDisableCounters ) {
// Number of views
- $views = (int) $dbr->selectField(
+ $views = (int)$dbr->selectField(
'page',
'page_counter',
array( 'page_id' => $id ),
}
// Number of page watchers
- $watchers = (int) $dbr->selectField(
+ $watchers = (int)$dbr->selectField(
'watchlist',
'COUNT(*)',
array(
$result['watchers'] = $watchers;
// Total number of edits
- $edits = (int) $dbr->selectField(
+ $edits = (int)$dbr->selectField(
'revision',
'COUNT(rev_page)',
array( 'rev_page' => $id ),
$result['edits'] = $edits;
// Total number of distinct authors
- $authors = (int) $dbr->selectField(
+ $authors = (int)$dbr->selectField(
'revision',
'COUNT(DISTINCT rev_user_text)',
array( 'rev_page' => $id ),
$threshold = $dbr->timestamp( time() - $wgRCMaxAge );
// Recent number of edits
- $edits = (int) $dbr->selectField(
+ $edits = (int)$dbr->selectField(
'revision',
'COUNT(rev_page)',
array(
$result['recent_edits'] = $edits;
// Recent number of distinct authors
- $authors = (int) $dbr->selectField(
+ $authors = (int)$dbr->selectField(
'revision',
'COUNT(DISTINCT rev_user_text)',
array(
// Subpages of this page (redirects)
$conds['page_is_redirect'] = 1;
- $result['subpages']['redirects'] = (int) $dbr->selectField(
+ $result['subpages']['redirects'] = (int)$dbr->selectField(
'page',
'COUNT(page_id)',
$conds,
// Subpages of this page (non-redirects)
$conds['page_is_redirect'] = 0;
- $result['subpages']['nonredirects'] = (int) $dbr->selectField(
+ $result['subpages']['nonredirects'] = (int)$dbr->selectField(
'page',
'COUNT(page_id)',
$conds,
}
// Counts for the number of transclusion links (to/from)
- $result['transclusion']['to'] = (int) $dbr->selectField(
+ $result['transclusion']['to'] = (int)$dbr->selectField(
'templatelinks',
'COUNT(tl_from)',
array(
__METHOD__
);
- $result['transclusion']['from'] = (int) $dbr->selectField(
+ $result['transclusion']['from'] = (int)$dbr->selectField(
'templatelinks',
'COUNT(*)',
array( 'tl_from' => $title->getArticleID() ),
case 'registered-checkmatrix':
// A key for a multiselect or checkmatrix option.
$validation = true;
- $value = $value !== null ? (bool) $value : null;
+ $value = $value !== null ? (bool)$value : null;
break;
case 'userjs':
// Allow non-default preferences prefixed with 'userjs-', to be set by user scripts
$allowException = !empty( $allowFrom );
}
if ( $allowException ) {
- $data['externalimages'] = (array) $allowFrom;
+ $data['externalimages'] = (array)$allowFrom;
$this->getResult()->setIndexedTagName( $data['externalimages'], 'prefix' );
}
$default = $this->getDefault();
$usersToCheck = array();
- foreach ( (array) $users as $value ) {
+ foreach ( (array)$users as $value ) {
$name = self::normalizeUsername( $value );
// Skip users whose gender setting we already know
if ( !isset( $this->cache[$name] ) ) {
self::$query[] = array(
'sql' => $sql,
'function' => $function,
- 'master' => (bool) $isMaster,
+ 'master' => (bool)$isMaster,
'time' => 0.0,
'_start' => microtime( true ),
);
public static function insertToDefault( $data, array $params = array() ) {
global $wgDefaultExternalStore;
- return self::insertWithFallback( (array) $wgDefaultExternalStore, $data, $params );
+ return self::insertWithFallback( (array)$wgDefaultExternalStore, $data, $params );
}
/**
// Input is like ofield=2134 or just the number
if ( strpos( $string, 'field=' ) === 1 ) {
list( , $field ) = explode( '=', $string );
- return (int) $field;
+ return (int)$field;
} else {
- return (int) $string;
+ return (int)$string;
}
}
*/
public static function newFromRow( $row ) {
if ( is_array( $row ) && isset( $row['rc_logid'] ) ) {
- return new RCDatabaseLogEntry( (object) $row );
+ return new RCDatabaseLogEntry( (object)$row );
} else {
return new self( $row );
}
public function getPerformer() {
if ( !$this->performer ) {
- $userId = (int) $this->row->log_user;
+ $userId = (int)$this->row->log_user;
if ( $userId !== 0 ) { // logged-in users
if ( isset( $this->row->user_name ) ) {
$this->performer = User::newFromRow( $this->row );
public function getPerformer() {
if ( !$this->performer ) {
- $userId = (int) $this->row->rc_user;
+ $userId = (int)$this->row->rc_user;
if ( $userId !== 0 ) {
$this->performer = User::newFromId( $userId );
} else {
'log_title' => $this->getTarget()->getDBkey(),
'log_page' => $this->getTarget()->getArticleID(),
'log_comment' => $comment,
- 'log_params' => serialize( (array) $this->getParameters() ),
+ 'log_params' => serialize( (array)$this->getParameters() ),
);
$dbw->insert( 'logging', $data, __METHOD__ );
$this->id = !is_null( $id ) ? $id : $dbw->insertId();
$this->getSubtype(),
$this->getTarget(),
$this->getComment(),
- serialize( (array) $this->getParameters() ),
+ serialize( (array)$this->getParameters() ),
$newId,
$formatter->getIRCActionComment() // Used for IRC feeds
);
}
public function getDeleted() {
- return (int) $this->deleted;
+ return (int)$this->deleted;
}
}
$val = null;
return;
} else {
- $nVal = (float) $val;
+ $nVal = (float)$val;
if ( $nVal < 0 ) {
// We do < 0 here instead of < -1 here, since
// the values between 0 and -1 are also illegal
return false;
}
- return (bool) $db->affectedRows();
+ return (bool)$db->affectedRows();
}
/**
}
public function addModules( $modules ) {
- $this->mModules = array_merge( $this->mModules, (array) $modules );
+ $this->mModules = array_merge( $this->mModules, (array)$modules );
}
public function addModuleScripts( $modules ) {
$prof .= sprintf( $format,
substr( $fname, 0, $nameWidth ),
$calls,
- (float) ( $elapsed * 1000 ),
- (float) ( $elapsed * 1000 ) / $calls,
+ (float)( $elapsed * 1000 ),
+ (float)( $elapsed * 1000 ) / $calls,
$percent,
$memory,
( $this->mMin[$fname] * 1000.0 ),
foreach ( $this->mCollated as $name => $elapsed ) {
$eventCount = $this->mCalls[$name];
- $timeSum = (float) ( $elapsed * 1000 );
+ $timeSum = (float)( $elapsed * 1000 );
$memorySum = (float)$this->mMemory[$name];
$name = substr( $name, 0, 255 );
*/
public function getRandomTitle() {
// Convert to float, since we do math with the random number.
- $rand = (float) wfRandom();
+ $rand = (float)wfRandom();
$title = null;
// Given that timestamps are rather unevenly distributed, we also
$template->set( 'usereason', $user->isLoggedIn() );
$template->set( 'remember', $user->getOption( 'rememberpassword' ) || $this->mRemember );
$template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
- $template->set( 'stickhttps', (int) $this->mStickHTTPS );
+ $template->set( 'stickhttps', (int)$this->mStickHTTPS );
if ( $this->mType === 'signup' && $user->isLoggedIn() ) {
$template->set( 'createAnother', true );
protected function showHideLink( $options, $message, $name, $value ) {
$label = $this->msg( $value ? 'show' : 'hide' )->escaped();
- $options[$name] = 1 - (int) $value;
+ $options[$name] = 1 - (int)$value;
return $this->msg( $message )->rawParams( Linker::linkKnown( $this->getTitle(), $label, array(), $options ) )->escaped();
}
foreach ( $forms as $index => $form ) {
if ( preg_match( '/^\d+=/i', $form ) ) {
$pos = strpos( $form, '=' );
- if ( substr( $form, 0, $pos ) === (string) $count ) {
+ if ( substr( $form, 0, $pos ) === (string)$count ) {
return substr( $form, $pos + 1 );
}
unset( $forms[$index] );
$numLatin = preg_match_all( "/[šđč枊ĐČĆŽ]/u", $text, $dummy );
if ( $variant == 'sr-ec' ) {
- return (boolean) ( $numCyrillic > $numLatin );
+ return $numCyrillic > $numLatin;
} elseif ( $variant == 'sr-el' ) {
- return (boolean) ( $numLatin > $numCyrillic );
+ return $numLatin > $numCyrillic;
} else {
return false;
}
return !$right->isNumberWithin( $left );
case 'mod':
if ( is_int( $left ) ) {
- return (int) fmod( $left, $right );
+ return (int)fmod( $left, $right );
}
return fmod( $left, $right );
case ',':