* instead of just plain userrights
* @return bool
*/
- public static function userCanBitfield( $bitfield, $field, User $user = null ,
+ public static function userCanBitfield( $bitfield, $field, User $user = null,
Title $title = null
) {
if ( $bitfield & $field ) { // aspect is deleted
} else {
$text = $title->getPrefixedText();
wfDebug( "Checking for $permissionlist on $text due to $field match on $bitfield\n" );
- foreach( $permissions as $perm ) {
+ foreach ( $permissions as $perm ) {
if ( $title->userCan( $perm, $user ) ) {
return true;
}
// Register skins
// Use a closure to avoid leaking into global state
-call_user_func( function() use ( $wgValidSkinNames ) {
+call_user_func( function () use ( $wgValidSkinNames ) {
$factory = SkinFactory::getDefaultInstance();
foreach ( $wgValidSkinNames as $name => $skin ) {
- $factory->register( $name, $skin, function() use ( $name, $skin ) {
+ $factory->register( $name, $skin, function () use ( $name, $skin ) {
$class = "Skin$skin";
return new $class( $name );
} );
}
// Register a hidden "fallback" skin
- $factory->register( 'fallback', 'Fallback', function() {
+ $factory->register( 'fallback', 'Fallback', function () {
return new SkinFallback;
} );
} );
} elseif ( $action == 'delete' ) {
$tempErrors = $this->checkPageRestrictions( 'edit',
$user, array(), $doExpensiveQueries, true );
- if( !$tempErrors ) {
+ if ( !$tempErrors ) {
$tempErrors = $this->checkCascadingSourcesRestrictions( 'edit',
$user, $tempErrors, $doExpensiveQueries, true );
}
}
$dbw = wfGetDB( DB_MASTER );
- foreach( array_chunk( $rows, 100 ) as $toInsert ) {
+ foreach ( array_chunk( $rows, 100 ) as $toInsert ) {
// Use INSERT IGNORE to avoid overwriting the notification timestamp
// if there's already an entry for this page
$dbw->insert( 'watchlist', $toInsert, __METHOD__, 'IGNORE' );
if ( $this->getOptions() ) {
$attribs['data-hide-if'] = FormatJson::encode(
- array( '!==', $this->mName . '-select', 'other' )
+ array( '!==', $this->mName . '-select', 'other' )
);
}
}
if ( $useMediaWikiUIEverywhere ) {
- if ( isset( $attrs['class' ] ) ) {
+ if ( isset( $attrs['class'] ) ) {
$attrs['class'] .= ' mw-ui-button';
} else {
$attrs['class'] = 'mw-ui-button';
if ( $expiry > 2592000 && $expiry < 1000000000 ) {
$expiry = 2592000;
}
- return (int) $expiry;
+ return (int)$expiry;
}
/**
* @param int $contextchars average number of characters per line
* @return string
*/
- public function highlightNone( $text, $contextlines, $contextchars) {
+ public function highlightNone( $text, $contextlines, $contextchars ) {
$match = array();
$text = ltrim( $text ) . "\n"; // make sure the preg_match may find the last line
- $text = str_replace( "\n\n", "\n", $text); // remove empty lines
- preg_match( "/^(.*\n){0,$contextlines}/", $text , $match);
+ $text = str_replace( "\n\n", "\n", $text ); // remove empty lines
+ preg_match( "/^(.*\n){0,$contextlines}/", $text, $match );
$text = htmlspecialchars( substr( trim( $match[0] ), 0, $contextlines * $contextchars ) ); // trim and limit to max number of chars
return str_replace( "\n", '<br>', $text );
}
* to be, but doing so would change the case of i18n message keys).
* @param string $displayName For backwards-compatibility with old skin loading system. This is
* the text used as skin's human-readable name when the 'skinname-<skin>' message is not
- * available. It should be the same as the skin name provided in $wgExtensionCredits.
+ * available. It should be the same as the skin name provided in $wgExtensionCredits.
* @param callable $callback Callback that takes the skin name as an argument
* @throws InvalidArgumentException If an invalid callback is provided
*/
foreach ( $importSources as $key => $value ) {
if ( is_int( $key ) ) {
$key = $value;
- } else if ( $value !== $key ) {
+ } elseif ( $value !== $key ) {
$needSubprojectField = true;
}
return $this->showSkipped();
}
$out = MWTidy::tidy( $out );
- $out = preg_replace( '/\s+$/', '', $out);
+ $out = preg_replace( '/\s+$/', '', $out );
}
if ( isset( $opts['showtitle'] ) ) {
* @param string $message
* @param bool $isHtml
*/
- public static function assertTag($matcher, $actual, $message = '', $isHtml = true) {
+ public static function assertTag( $matcher, $actual, $message = '', $isHtml = true ) {
//trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
- $dom = PHPUnit_Util_XML::load($actual, $isHtml);
- $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml);
- $matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
+ $dom = PHPUnit_Util_XML::load( $actual, $isHtml );
+ $tags = PHPUnit_Util_XML::findNodes( $dom, $matcher, $isHtml );
+ $matched = count( $tags ) > 0 && $tags[0] instanceof DOMNode;
- self::assertTrue($matched, $message);
+ self::assertTrue( $matched, $message );
}
}
class DeferredUpdatesTest extends MediaWikiTestCase {
public function testDoUpdates() {
- $updates = array (
+ $updates = array(
'1' => 'deferred update 1',
'2' => 'deferred update 2',
'3' => 'deferred update 3',
function () use ( $updates ) {
echo $updates['2'];
DeferredUpdates::addCallableUpdate(
- function() use ( $updates ) {
+ function () use ( $updates ) {
echo $updates['2-1'];
}
);
$this->markTestSkipped( "SKIPPED: tidy extension is not installed.\n" );
} else {
$out = MWTidy::tidy( $out );
- $out = preg_replace( '/\s+$/', '', $out);
+ $out = preg_replace( '/\s+$/', '', $out );
}
}
array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ),
array( "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ),
array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
- array( $testMathML , $testMathML, '<math> should survive tidy' ),
+ array( $testMathML, $testMathML, '<math> should survive tidy' ),
);
}
}
SkinFactory::getDefaultInstance()->register(
'fakeskin',
'FakeSkin',
- function(){
+ function () {
}
);
}
public function testGetSkinNames() {
$factory = new SkinFactory();
// A fake callback we can use that will never be called
- $callback = function() {};
+ $callback = function () {
+ // NOP
+ };
$factory->register( 'skin1', 'Skin1', $callback );
$factory->register( 'skin2', 'Skin2', $callback );
$names = $factory->getSkinNames();
$input = $this->checkSection( array( 'wikitext', 'input' ), false );
$result = $this->checkSection( array( 'html/php', 'html/*', 'html', 'result' ), false );
// some tests have "with tidy" and "without tidy" variants
- $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy'), false );
+ $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy' ), false );
if ( $tidy != false ) {
if ( $this->nextSubTest == 0 ) {
if ( $result != false ) {
function readNextTest() {
# Run additional subtests of previous test
- while ( $this->nextSubTest > 0 )
- if ( $this->setupCurrentTest() )
+ while ( $this->nextSubTest > 0 ) {
+ if ( $this->setupCurrentTest() ) {
return true;
+ }
+ }
$this->clearSection();
# Reset hooks for the delayed test object
if ( $this->section == 'end' ) {
$this->checkSection( 'test' );
do {
- if ( $this->setupCurrentTest() )
+ if ( $this->setupCurrentTest() ) {
return true;
+ }
} while ( $this->nextSubTest > 0 );
# go on to next test (since this was disabled)
$this->clearSection();