public static function hash( $s ) {
$h = 5381;
for ( $i = 0; $i < strlen( $s ); $i++ ) {
- $h5 = ($h << 5) & 0xffffffff;
+ $h5 = ( $h << 5 ) & 0xffffffff;
// Do a 32-bit sum
// Inlined here for speed
- $sum = ($h & 0x3fffffff) + ($h5 & 0x3fffffff);
+ $sum = ( $h & 0x3fffffff ) + ( $h5 & 0x3fffffff );
$h =
(
( $sum & 0x40000000 ? 1 : 0 )
$secureName = $title->getPrefixedDBkey();
if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
# Use an @ character to prevent collision with page names
- $this->rc_cache['@@' . ($this->rcMoveIndex++)] = array( $rc );
+ $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $rc );
} else {
# Logs are grouped by type
if ( $type == RC_LOG ) {
public function parse() {
$this->initParse();
$this->pushState( 'file' );
- $this->pushPath( '@extra-' . ($this->serial++) );
+ $this->pushPath( '@extra-' . ( $this->serial++ ) );
$token = $this->firstToken();
while ( !$token->isEnd() ) {
}
$this->skipSpace();
$this->expect( ';' );
- $this->nextPath( '@extra-' . ($this->serial++) );
+ $this->nextPath( '@extra-' . ( $this->serial++ ) );
break;
case 'expression':
$token = $this->skipSpace();
$this->skipSpace();
$this->expect( '(' );
$this->skipSpace();
- $this->pushPath( '@extra-' . ($this->serial++) );
+ $this->pushPath( '@extra-' . ( $this->serial++ ) );
if ( $this->isAhead( ')' ) ) {
// Empty array
$this->pushState( 'array end' );
$this->endPathValue();
$this->markComma();
$this->nextToken();
- $this->nextPath( '@extra-' . ($this->serial++) );
+ $this->nextPath( '@extra-' . ( $this->serial++ ) );
// Look ahead to find ending bracket
if ( $this->isAhead( ")" ) ) {
// Found ending bracket, no continuation
return self::formatDiffRow( $titleObj,
$row->rc_last_oldid, $row->rc_this_oldid,
$timestamp,
- ($row->rc_deleted & Revision::DELETED_COMMENT)
+ $row->rc_deleted & Revision::DELETED_COMMENT
? wfMessage( 'rev-deleted-comment' )->escaped()
: $row->rc_comment,
$actiontext
'id' => "{$this->mID}-$thisTag",
'value' => $thisTag,
);
- $checked = in_array( $thisTag, (array)$value, true);
+ $checked = in_array( $thisTag, (array)$value, true );
if ( $this->isTagForcedOff( $thisTag ) ) {
$checked = false;
$thisAttribs['disabled'] = 1;
$thisTag = "$column-$row";
if ( $this->isTagForcedOff( $thisTag ) ) {
$res[$thisTag] = false;
- } elseif ($this->isTagForcedOn( $thisTag ) ) {
+ } elseif ( $this->isTagForcedOn( $thisTag ) ) {
$res[$thisTag] = true;
} else {
$res[$thisTag] = in_array( $thisTag, $data );
*/
function replace( $replacement, $subject, $limit = -1 ) {
$res = preg_replace( $this->getRegex(), StringUtils::escapeRegexReplacement( $replacement ), $subject, $limit );
- $this->mModified = !($res === $subject);
+ $this->mModified = $res !== $subject;
return $res;
}
*/
function substituteCallback( $text, $callback ) {
$res = preg_replace_callback( $this->getVariableRegex(), $callback, $text );
- $this->mModified = !($res === $text);
+ $this->mModified = $res !== $text;
return $res;
}
}
$result = preg_replace( $search, $replace, $subject );
- return !($result === $subject);
+ return $result !== $subject;
}
/**
foreach ( $this->parameters as $n => $param ) {
list( $paramType, $value ) = $this->extractParam( $param );
if ( $type === $paramType ) {
- $replacementKeys['$' . ($n + 1)] = $value;
+ $replacementKeys['$' . ( $n + 1 )] = $value;
}
}
$message = strtr( $message, $replacementKeys );
$this->doQuery();
}
// Hide navigation by default if there is nothing to page
- return !($this->mIsFirst && $this->mIsLast);
+ return !( $this->mIsFirst && $this->mIsLast );
}
/**
'mwProtect-reason', 4 );
$scExpiryOptions = wfMessage( 'protect-expiry-options' )->inContentLanguage()->text();
- $showProtectOptions = ($scExpiryOptions !== '-' && !$this->disabled);
+ $showProtectOptions = $scExpiryOptions !== '-' && !$this->disabled;
$mProtectexpiry = Xml::label(
wfMessage( 'protectexpiry' )->text(),
* @return Boolean
*/
private static function validateCodepoint( $codepoint ) {
- return ($codepoint == 0x09)
- || ($codepoint == 0x0a)
- || ($codepoint == 0x0d)
- || ($codepoint >= 0x20 && $codepoint <= 0xd7ff)
- || ($codepoint >= 0xe000 && $codepoint <= 0xfffd)
- || ($codepoint >= 0x10000 && $codepoint <= 0x10ffff);
+ return $codepoint == 0x09
+ || $codepoint == 0x0a
+ || $codepoint == 0x0d
+ || ( $codepoint >= 0x20 && $codepoint <= 0xd7ff )
+ || ( $codepoint >= 0xe000 && $codepoint <= 0xfffd )
+ || ( $codepoint >= 0x10000 && $codepoint <= 0x10ffff );
}
/**
* @return bool The value of the setting requested.
*/
public function getBool( $setting, $wiki, $suffix = null, $wikiTags = array() ) {
- return (bool)($this->get( $setting, $wiki, $suffix, array(), $wikiTags ) );
+ return (bool)$this->get( $setting, $wiki, $suffix, array(), $wikiTags );
}
/**
* @return Boolean: true if $obj is not an instance of StubObject class.
*/
static function isRealObject( $obj ) {
- return is_object( $obj ) && !($obj instanceof StubObject);
+ return is_object( $obj ) && !$obj instanceof StubObject;
}
/**
function _unstub( $name = '_unstub', $level = 2 ) {
static $recursionLevel = 0;
- if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) ) {
+ if ( !$GLOBALS[$this->mGlobal] instanceof StubObject ) {
return $GLOBALS[$this->mGlobal]; // already unstubbed.
}
$selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode;
$options = "\n";
foreach ( $languages as $code => $name ) {
- $options .= Xml::option( "$code - $name", $code, ($code == $selected) ) . "\n";
+ $options .= Xml::option( "$code - $name", $code, $code == $selected ) . "\n";
}
$attrs = array( 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' );
*/
public function addOption( $name, $value = false ) {
// Stab stab stab
- $value = ($value !== false) ? $value : $name;
+ $value = $value !== false ? $value : $name;
$this->options[] = array( $name => $value );
}
* @return bool
*/
public function isEmpty() {
- return ($this->getSize() == 0);
+ return $this->getSize() == 0;
}
/**
*/
public function isDeleted( $field ) {
$this->load();
- return ($this->deleted & $field) == $field;
+ return ( $this->deleted & $field ) == $field;
}
/**
*/
function isDeleted( $field ) {
$this->load();
- return ($this->deleted & $field) == $field;
+ return ( $this->deleted & $field ) == $field;
}
/**
public function showHeader( $type ) {
wfDeprecated( __METHOD__, '1.19' );
// If only one log type is used, then show a special message...
- $headerType = (count( $type ) == 1) ? $type[0] : '';
+ $headerType = count( $type ) == 1 ? $type[0] : '';
$out = $this->getOutput();
if ( LogPage::isLogType( $headerType ) ) {
$page = new LogPage( $headerType );
if ( $blockLength != 11 ) {
wfDebug( __METHOD__ . ' GIF application block with wrong length' );
- fseek( $fh, -($blockLength + 1), SEEK_CUR );
+ fseek( $fh, -( $blockLength + 1 ), SEEK_CUR );
self::skipBlock( $fh );
continue;
}
} else {
// unrecognized extension block
- fseek( $fh, -($blockLength + 1), SEEK_CUR );
+ fseek( $fh, -( $blockLength + 1 ), SEEK_CUR );
self::skipBlock( $fh );
continue;
}
function canRender( $file ) {
global $wgTiffThumbnailType;
return (bool)$wgTiffThumbnailType
- || ($file->getRepo() instanceof ForeignAPIRepo);
+ || $file->getRepo() instanceof ForeignAPIRepo;
}
/**
# Adjust for profiling overhead (except special values with elapsed=0
if ( $elapsed ) {
$elapsed -= $overheadInternal;
- $elapsed -= ($subcalls * $overheadTotal);
- $memory -= ($subcalls * $overheadMemory);
+ $elapsed -= ( $subcalls * $overheadTotal );
+ $memory -= ( $subcalls * $overheadMemory );
}
}
$calls = $this->mCalls[$fname];
$percent = $total ? 100. * $elapsed / $total : 0;
$memory = $this->mMemory[$fname];
- $prof .= sprintf( $format, substr( $fname, 0, $nameWidth ), $calls, (float) ($elapsed * 1000), (float) ($elapsed * 1000) / $calls, $percent, $memory, ( $this->mMin[$fname] * 1000.0 ), ( $this->mMax[$fname] * 1000.0 ), $this->mOverhead[$fname] );
+ $prof .= sprintf( $format,
+ substr( $fname, 0, $nameWidth ),
+ $calls,
+ (float) ( $elapsed * 1000 ),
+ (float) ( $elapsed * 1000 ) / $calls,
+ $percent,
+ $memory,
+ ( $this->mMin[$fname] * 1000.0 ),
+ ( $this->mMax[$fname] * 1000.0 ),
+ $this->mOverhead[$fname]
+ );
}
$prof .= "\nTotal: $total\n\n";
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 );
// Kludge
- $timeSum = ($timeSum >= 0) ? $timeSum : 0;
- $memorySum = ($memorySum >= 0) ? $memorySum : 0;
+ $timeSum = $timeSum >= 0 ? $timeSum : 0;
+ $memorySum = $memorySum >= 0 ? $memorySum : 0;
$dbw->update( 'profiling',
array(
$out .= '</tr>';
}
}
- if ( ($n % 3) != 0 ) {
+ if ( $n % 3 != 0 ) {
$out .= '</tr>';
}
$out .= Xml::closeElement( 'table' );
// Calculate cutoff
$cutoff_unixtime = time() - ( $opts['days'] * 86400 );
- $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
+ $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
$cutoff = $dbr->timestamp( $cutoff_unixtime );
$fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
if ( $val == 1 ) {
$newBits |= $const; // $const is the *_deleted const
} elseif ( $val == -1 ) {
- $newBits |= ($oldfield & $const); // use existing
+ $newBits |= ( $oldfield & $const ); // use existing
}
}
return $newBits;
return;
}
- $this->fail('Expected MWException indicating missing parameters but none was thrown.');
+ $this->fail( 'Expected MWException indicating missing parameters but none was thrown.' );
}
public function testInstantiationWithMinimumRequiredParameters() {
$form = new HTMLCheckMatrix( self::$defaultOptions );
- $this->assertTrue(true); // form instantiation must throw exception on failure
+ $this->assertTrue( true ); // form instantiation must throw exception on failure
}
public function testValidateCallsUserDefinedValidationCallback() {
public function testValidateAllowsOnlyKnownTags() {
$field = new HTMLCheckMatrix( self::$defaultOptions );
- $this->assertInternalType('string', $this->validate( $field, array( 'foo' ) ) );
+ $this->assertInternalType( 'string', $this->validate( $field, array( 'foo' ) ) );
}
public function testValidateAcceptsPartialTagList() {
'c2-r1' => true,
'c2-r2' => false,
);
- $this->assertEquals($expected, $field->filterDataForSubmit( array() ) );
+ $this->assertEquals( $expected, $field->filterDataForSubmit( array() ) );
}
public function testValuesForcedOffRemainOff() {
'c2-r2' => false,
);
// array_keys on the result simulates submitting all fields checked
- $this->assertEquals($expected, $field->filterDataForSubmit( array_keys($expected) ) );
+ $this->assertEquals( $expected, $field->filterDataForSubmit( array_keys( $expected ) ) );
}
protected function validate( HTMLFormField $field, $submitted ) {
$ring = new HashRing( array( 's1' => 1, 's2' => 1, 's3' => 2, 's4' => 2, 's5' => 2, 's6' => 3 ) );
$locations = array();
- for ( $i=0; $i<20; $i++ ) {
+ for ( $i = 0; $i < 20; $i++ ) {
$locations[ "hello$i"] = $ring->getLocation( "hello$i" );
}
$expectedLocations = array(
$this->assertEquals( $expectedLocations, $locations, 'Items placed at proper locations' );
$locations = array();
- for ( $i=0; $i<5; $i++ ) {
+ for ( $i = 0; $i < 5; $i++ ) {
$locations[ "hello$i"] = $ring->getLocations( "hello$i", 2 );
}
# actual thumbnails to do parser testing, we only care about receiving
# a ThumbnailImage properly initialized.
global $wgMediaHandlers;
- foreach( $wgMediaHandlers as $type => $handler ) {
+ foreach ( $wgMediaHandlers as $type => $handler ) {
$tmpGlobals['wgMediaHandlers'][$type] = 'MockBitmapHandler';
}
}
$backend = RepoGroup::singleton()->getLocalRepo()->getBackend();
- if( $backend instanceof MockFileBackend ) {
+ if ( $backend instanceof MockFileBackend ) {
# In memory backend, so dont bother cleaning them up.
return;
}
$user = $this->getMock( 'User' );
$user->expects( $this->any() )
- ->method('isAnon')
- ->will( $this->returnValue(false) );
+ ->method( 'isAnon' )
+ ->will( $this->returnValue( false ) );
# Yeah foreach requires an array, not NULL =(
$user->expects( $this->any() )
- ->method('getEffectiveGroups')
+ ->method( 'getEffectiveGroups' )
->will( $this->returnValue( array() ) );
# The mocked user has a long nickname
$user->expects( $this->any() )
- ->method('getOption')
+ ->method( 'getOption' )
->will( $this->returnValueMap( array(
array( 'nickname', null, false, 'superlongnickname' ),
)
}
protected function doCreateInternal( array $params ) {
- if( isset( $params['content'] ) ) {
+ if ( isset( $params['content'] ) ) {
$content = $params['content'];
} else {
$content = 'Default mocked file content';
}
- $this->debug(serialize($params));
+ $this->debug( serialize( $params ) );
$dst = $params['dst'];
$this->mocked[$dst] = $content;
return Status::newGood();
}
protected function doStoreInternal( array $params ) {
- $this->debug(serialize($params));
+ $this->debug( serialize( $params ) );
return $this->doCreateInternal( $params );
}
protected function doCopyInternal( array $params ) {
- $this->debug(serialize($params));
+ $this->debug( serialize( $params ) );
$src = $params['src'];
$dst = $params['dst'];
$this->mocked[$dst] = $this->mocked[$src];
}
protected function doDeleteInternal( array $params ) {
- $this->debug(serialize($params));
+ $this->debug( serialize( $params ) );
$src = $params['src'];
unset( $this->mocked[$src] );
return Status::newGood();
protected function doGetFileStat( array $params ) {
$src = $params['src'];
- if( array_key_exists( $src, $this->mocked ) ) {
+ if ( array_key_exists( $src, $this->mocked ) ) {
$this->debug( "('$src') found" );
return array(
'mtime' => wfTimestamp( TS_MW ),
protected function doGetLocalCopyMulti( array $params ) {
$tmpFiles = array(); // (path => MockFSFile)
- $this->debug( '(' . serialize($params) . ')' );
- foreach( $params['srcs'] as $src ) {
+ $this->debug( '(' . serialize( $params ) . ')' );
+ foreach ( $params['srcs'] as $src ) {
$tmpFiles[$src] = new MockFSFile(
- wfTempDir() . '/' . wfRandomString(32)
+ wfTempDir() . '/' . wfRandomString( 32 )
);
}
return $tmpFiles;