$this->mode = "";
- if ( ! empty( $_GET["rs"] ) ) {
+ if ( !empty( $_GET["rs"] ) ) {
$this->mode = "get";
}
switch ( $this->mode ) {
case 'get':
$this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : '';
- if ( ! empty( $_GET["rsargs"] ) ) {
+ if ( !empty( $_GET["rsargs"] ) ) {
$this->args = $_GET["rsargs"];
} else {
$this->args = array();
break;
case 'post':
$this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : '';
- if ( ! empty( $_POST["rsargs"] ) ) {
+ if ( !empty( $_POST["rsargs"] ) ) {
$this->args = $_POST["rsargs"];
} else {
$this->args = array();
wfProfileIn( __METHOD__ );
- if ( ! in_array( $this->func_name, $wgAjaxExportList ) ) {
+ if ( !in_array( $this->func_name, $wgAjaxExportList ) ) {
wfDebug( __METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n" );
wfHttpError(
* @param string $text
*/
function addText( $text ) {
- if ( ! $this->mDisabled && $text ) {
+ if ( !$this->mDisabled && $text ) {
$this->mText .= $text;
}
}
* Output text
*/
function printText() {
- if ( ! $this->mDisabled ) {
+ if ( !$this->mDisabled ) {
print $this->mText;
}
}
$responseTime = round( ( microtime( true ) - $wgRequestTime ) * 1000 );
$reportVars = array( 'wgBackendResponseTime' => $responseTime );
if ( $wgShowHostnames ) {
- $reportVars[ 'wgHostname' ] = wfHostname();
+ $reportVars['wgHostname'] = wfHostname();
}
return Skin::makeVariablesScript( $reportVars );
}
private function fixLibXML( $html ) {
wfProfileIn( __METHOD__ );
static $replacements;
- if ( ! $replacements ) {
+ if ( !$replacements ) {
// We don't include rules like '"' => '"' because entities had already been
// normalized by libxml. Using this function with input not sanitized by libxml is UNSAFE!
$replacements = new ReplacementArray( array(
if ( $this->followRedirects && $this->canFollowRedirects() ) {
wfSuppressWarnings();
- if ( ! curl_setopt( $curlHandle, CURLOPT_FOLLOWLOCATION, true ) ) {
+ if ( !curl_setopt( $curlHandle, CURLOPT_FOLLOWLOCATION, true ) ) {
wfDebug( __METHOD__ . ": Couldn't set CURLOPT_FOLLOWLOCATION. " .
"Probably safe_mode or open_basedir is set.\n" );
// Continue the processing. If it were in curl_setopt_array,
private function handleSiteInfo() {
// Site info is useful, but not actually used for dump imports.
// Includes a quick short-circuit to save performance.
- if ( ! $this->mSiteInfoCallback ) {
+ if ( !$this->mSiteInfoCallback ) {
$this->reader->next();
return true;
}
$query = '', $unused1 = '', $unused2 = '', $time = false
) {
global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
- if ( ! $title instanceof Title ) {
+ if ( !$title instanceof Title ) {
return "<!-- ERROR -->" . htmlspecialchars( $label );
}
wfProfileIn( __METHOD__ );
$group = $module->getGroup();
// Modules in groups different than the ones listed on top (see $styles assignment)
// will be placed in the "other" group
- $styles[ isset( $styles[$group] ) ? $group : 'other' ][] = $name;
+ $styles[isset( $styles[$group] ) ? $group : 'other'][] = $name;
}
// We want site, private and user styles to override dynamically added
*/
static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
foreach ( MWNamespace::getValidNamespaces() as $n ) {
- $defaultPreferences[ 'searchNs' . $n ] = array(
+ $defaultPreferences['searchNs' . $n] = array(
'type' => 'api',
);
}
}
// Back compatibility for $wgRateLimitLog deprecated with 1.23
-if ( $wgRateLimitLog && ! array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
+if ( $wgRateLimitLog && !array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
$wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
}
if ( self::$mErrorString ) {
wfDebug( "Error sending mail: " . self::$mErrorString . "\n" );
return Status::newFatal( 'php-mail-error', self::$mErrorString );
- } elseif ( ! $sent ) {
+ } elseif ( !$sent ) {
// mail function only tells if there's an error
wfDebug( "Unknown error sending mail\n" );
return Status::newFatal( 'php-mail-error-unknown' );
// @todo: deprecate constructing with Skin
$context = $obj->getContext();
} else {
- if ( ! $obj instanceof IContextSource ) {
+ if ( !$obj instanceof IContextSource ) {
throw new MWException( 'EnhancedChangesList must be constructed with a '
. 'context source or skin.' );
}
if ( !array_key_exists( $var, $GLOBALS ) ) {
throw new ConfigException( __METHOD__ . ": undefined variable: '$var'" );
}
- return $GLOBALS[ $var ];
+ return $GLOBALS[$var];
}
/**
* @param mixed $value value to set
*/
protected function setWithPrefix( $prefix, $name, $value ) {
- $GLOBALS[ $prefix . $name ] = $value;
+ $GLOBALS[$prefix . $name] = $value;
}
}
if ( $wgHitcounterUpdateFreq <= 1 || $dbw->getType() == 'sqlite' ) {
$id = $this->id;
$method = __METHOD__;
- $dbw->onTransactionIdle( function() use ( $dbw, $id, $method ) {
+ $dbw->onTransactionIdle( function () use ( $dbw, $id, $method ) {
try {
$dbw->update( 'page',
array( 'page_counter = page_counter + 1' ),
'mtime' => $this->convertSwiftDate( $rhdrs['last-modified'], TS_MW ),
// Empty objects actually return no content-length header in Ceph
'size' => isset( $rhdrs['content-length'] ) ? (int)$rhdrs['content-length'] : 0,
- 'sha1' => $rhdrs[ 'x-object-meta-sha1base36'],
+ 'sha1' => $rhdrs['x-object-meta-sha1base36'],
// Note: manifiest ETags are not an MD5 of the file
'md5' => ctype_xdigit( $rhdrs['etag'] ) ? $rhdrs['etag'] : null,
'xattr' => array( 'metadata' => $metadata, 'headers' => $headers )
return false;
}
- $this->tmpBucketedThumbCache[ $bucket ] = $tmpFile->getPath();
+ $this->tmpBucketedThumbCache[$bucket] = $tmpFile->getPath();
// For the caching to work, we need to make the tmp file survive as long as
// this object exists
$tmpFile->bind( $this );
}
// Try to avoid reading from storage if the file was generated by this script
- if ( isset( $this->tmpBucketedThumbCache[ $bucket ] ) ) {
- $tmpPath = $this->tmpBucketedThumbCache[ $bucket ];
+ if ( isset( $this->tmpBucketedThumbCache[$bucket] ) ) {
+ $tmpPath = $this->tmpBucketedThumbCache[$bucket];
if ( file_exists( $tmpPath ) ) {
return array(
'rawtext' => $skin,
'value' => $this->getVar( "skin-$skin", true ), // all found skins enabled by default
) ) .
- '<div class="config-skins-use-as-default">' . $radioButtons[ strtolower( $skin ) ] . '</div>' .
+ '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] . '</div>' .
'</div>';
}
} else {
$animation_post = array();
$decoderHint = array();
if ( $params['mimeType'] == 'image/jpeg' ) {
- $qualityVal = isset( $params['quality'] ) ? (string) $params['quality'] : null;
+ $qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
$quality = array( '-quality', $qualityVal ?: '80' ); // 80%
# Sharpening, see bug 6193
if ( ( $params['physicalWidth'] + $params['physicalHeight'] )
list( $radius, $sigma ) = explode( 'x', $wgSharpenParameter );
$im->sharpenImage( $radius, $sigma );
}
- $qualityVal = isset( $params['quality'] ) ? (string) $params['quality'] : null;
+ $qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
$im->setCompressionQuality( $qualityVal ?: 80 );
} elseif ( $params['mimeType'] == 'image/png' ) {
$im->setCompressionQuality( 95 );
* @return bool
*/
function validateParam( $name, $value ) {
- if ( $name === 'page' && trim( $value ) !== (string) intval( $value ) ) {
+ if ( $name === 'page' && trim( $value ) !== (string)intval( $value ) ) {
// Extra junk on the end of page, probably actually a caption
// e.g. [[File:Foo.djvu|thumb|Page 3 of the document shows foo]]
return false;
$hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
- if ( ! $hookResult ) {
+ if ( !$hookResult ) {
return;
}
$title = $this->mTitle;
$file = $this->mFile;
- if ( ! $file instanceof LocalFile ) {
+ if ( !$file instanceof LocalFile ) {
wfDebug( __CLASS__ . '::' . __METHOD__ . " is not supported for this file\n" );
return TitleArray::newFromResult( new FakeResultWrapper( array() ) );
}
$oldContent = $rev->getContent();
}
- if ( ! $oldContent ) {
+ if ( !$oldContent ) {
wfDebug( __METHOD__ . ": no page text\n" );
wfProfileOut( __METHOD__ );
return null;
}
$user = is_null( $user ) ? $wgUser : $user;
- if ( ! wfRunHooks( 'ArticleDelete', array( &$this, &$user, &$reason, &$error, &$status ) ) ) {
+ if ( !wfRunHooks( 'ArticleDelete', array( &$this, &$user, &$reason, &$error, &$status ) ) ) {
if ( $status->isOK() ) {
// Hook aborted but didn't set a fatal status
$status->fatal( 'delete-hook-aborted' );
);
}
- $registryData[ $name ] = array(
+ $registryData[$name] = array(
'version' => $mtime,
'dependencies' => $module->getDependencies(),
'group' => $module->getGroup(),
}
$offset = $endMatches[0][1] + strlen( $endMatches[0][0] );
}
- if ( ! $found ) {
+ if ( !$found ) {
// couldn't find appropriate closing tag, skip
$this->splitAndAdd( $textExt, $count, substr( $text, $start, strlen( $matches[0][0] ) ) );
$start += strlen( $matches[0][0] );
$succ = true;
// check if first text contains all terms
foreach ( $terms as $term ) {
- if ( ! preg_match( "/$patPre" . $term . "$patPost/ui", $firstText ) ) {
+ if ( !preg_match( "/$patPre" . $term . "$patPost/ui", $firstText ) ) {
$succ = false;
break;
}
$offsets[$first] = 0;
}
}
- if ( ! $snippets ) {
+ if ( !$snippets ) {
// match whole query on text
$this->process( $pat1, $textExt, $left, $contextchars, $snippets, $offsets );
// match whole query on templates/tables/images
$processed = array();
foreach ( $terms as $term ) {
- if ( ! isset( $processed[$term] ) ) {
+ if ( !isset( $processed[$term] ) ) {
$pat3 = "/$patPre(" . $term . ")$patPost/ui"; // highlight word
$extract = preg_replace( $pat3,
"\\1<span class='searchmatch'>\\2</span>\\3", $extract );
}
++$lineno;
$m = array();
- if ( ! preg_match( $pat1, $line, $m ) ) {
+ if ( !preg_match( $pat1, $line, $m ) ) {
continue;
}
--$contextlines;
$conds['pagelinks'][] = 'rd_from is NOT NULL';
}
- $queryFunc = function( $dbr, $table, $fromCol ) use ( $conds, $target, $limit ) {
+ $queryFunc = function ( $dbr, $table, $fromCol ) use ( $conds, $target, $limit ) {
global $wgUseLinkNamespaceDBFields;
// Read an extra row as an at-end check
$queryLimit = $limit + 1;
*/
function getMagic( $mw ) {
// Saves a function call
- if ( ! $this->mMagicHookDone ) {
+ if ( !$this->mMagicHookDone ) {
$this->doMagicHook();
}
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] );
if ( !isset( $format['avoid'] ) ) {
$format['avoid'] = false;
}
- if ( !isset( $format['noabbrevs' ] ) ) {
+ if ( !isset( $format['noabbrevs'] ) ) {
$format['noabbrevs'] = false;
}
$secondsMsg = wfMessage(
$linkTrail = '/^([a-zàâçéèêîœôû·’æäåāăëēïīòöōùü‘]+)(.*)$/sDu';
$dateFormats = array(
- 'mdy time' => 'H:i',
- 'mdy date' => 'F j, Y',
- 'mdy both' => 'F j, Y "a" H:i',
+ 'mdy time' => 'H:i',
+ 'mdy date' => 'F j, Y',
+ 'mdy both' => 'F j, Y "a" H:i',
- 'dmy time' => 'H:i',
- 'dmy date' => 'j F Y',
- 'dmy both' => 'j F Y "a" H:i',
+ 'dmy time' => 'H:i',
+ 'dmy date' => 'j F Y',
+ 'dmy both' => 'j F Y "a" H:i',
- 'ymd time' => 'H:i',
- 'ymd date' => 'Y F j',
- 'ymd both' => 'Y F j "a" H:i',
+ 'ymd time' => 'H:i',
+ 'ymd date' => 'Y F j',
+ 'ymd both' => 'Y F j "a" H:i',
);
$separatorTransformTable = array( ',' => "\xc2\xa0", '.' => ',' );
if ( preg_match_all( $regex, $instring, $matches, PREG_SET_ORDER ) ) {
foreach ( $matches as $bits ) {
- $key = strtolower( $bits[ 'k' ] );
- if ( !isset( $bits[ 'v' ] ) ) {
+ $key = strtolower( $bits['k'] );
+ if ( !isset( $bits['v'] ) ) {
$opts[$key] = true;
} else {
- preg_match_all( $valueregex, $bits[ 'v' ], $vmatches );
+ preg_match_all( $valueregex, $bits['v'], $vmatches );
$opts[$key] = array_map( array( $this, 'cleanupOption' ), $vmatches[0] );
if ( count( $opts[$key] ) == 1 ) {
$opts[$key] = $opts[$key][0];
public static function provideGetWikiTextAndHtml() {
$testCases = array();
- $testCases[ 'GoodStatus' ] = array(
+ $testCases['GoodStatus'] = array(
new Status(),
"Internal error: Status::getWikiText called for a good result, this is incorrect\n",
"<p>Internal error: Status::getWikiText called for a good result, this is incorrect\n</p>",
$status = new Status();
$status->ok = false;
- $testCases[ 'GoodButNoError' ] = array(
+ $testCases['GoodButNoError'] = array(
$status,
"Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n",
"<p>Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n</p>",
$status = new Status();
$status->warning( 'fooBar!' );
- $testCases[ '1StringWarning' ] = array(
+ $testCases['1StringWarning'] = array(
$status,
"<fooBar!>",
"<p><fooBar!>\n</p>",
$status = new Status();
$status->warning( 'fooBar!' );
$status->warning( 'fooBar2!' );
- $testCases[ '2StringWarnings' ] = array(
+ $testCases['2StringWarnings'] = array(
$status,
"* <fooBar!>\n* <fooBar2!>\n",
"<ul><li> <fooBar!></li>\n<li> <fooBar2!></li></ul>\n",
$status = new Status();
$status->warning( new Message( 'fooBar!', array( 'foo', 'bar' ) ) );
- $testCases[ '1MessageWarning' ] = array(
+ $testCases['1MessageWarning'] = array(
$status,
"<fooBar!>",
"<p><fooBar!>\n</p>",
$status = new Status();
$status->warning( new Message( 'fooBar!', array( 'foo', 'bar' ) ) );
$status->warning( new Message( 'fooBar2!' ) );
- $testCases[ '2MessageWarnings' ] = array(
+ $testCases['2MessageWarnings'] = array(
$status,
"* <fooBar!>\n* <fooBar2!>\n",
"<ul><li> <fooBar!></li>\n<li> <fooBar2!></li></ul>\n",
public static function provideGetMessage() {
$testCases = array();
- $testCases[ 'GoodStatus' ] = array(
+ $testCases['GoodStatus'] = array(
new Status(),
array( "Status::getMessage called for a good result, this is incorrect\n" ),
'internalerror_info'
$status = new Status();
$status->ok = false;
- $testCases[ 'GoodButNoError' ] = array(
+ $testCases['GoodButNoError'] = array(
$status,
array( "Status::getMessage: Invalid result object: no error text but not OK\n" ),
'internalerror_info'
$status = new Status();
$status->warning( 'fooBar!' );
- $testCases[ '1StringWarning' ] = array(
+ $testCases['1StringWarning'] = array(
$status,
array(),
'fooBar!'
$status = new Status();
$status->warning( new Message( 'fooBar!', array( 'foo', 'bar' ) ) );
- $testCases[ '1MessageWarning' ] = array(
+ $testCases['1MessageWarning'] = array(
$status,
array( 'foo', 'bar' ),
'fooBar!'
$status = new Status();
$status->warning( new Message( 'fooBar!', array( 'foo', 'bar' ) ) );
$status->warning( new Message( 'fooBar2!' ) );
- $testCases[ '2MessageWarnings' ] = array(
+ $testCases['2MessageWarnings'] = array(
$status,
array( new Message( 'fooBar!', array( 'foo', 'bar' ) ), new Message( 'fooBar2!' ) ),
"* \$1\n* \$2"
$data = $this->doApiRequest( array(
'action' => 'login',
- 'lgname' => self::$users[ $user ]->username,
- 'lgpassword' => self::$users[ $user ]->password ) );
+ 'lgname' => self::$users[$user]->username,
+ 'lgpassword' => self::$users[$user]->password ) );
$token = $data[0]['login']['token'];
array(
'action' => 'login',
'lgtoken' => $token,
- 'lgname' => self::$users[ $user ]->username,
- 'lgpassword' => self::$users[ $user ]->password,
+ 'lgname' => self::$users[$user]->username,
+ 'lgpassword' => self::$users[$user]->password,
),
$data[2]
);
$hasObject = false;
$hasArray = false;
foreach ( $trace as $frame ) {
- if ( ! isset( $frame['args'] ) ) {
+ if ( !isset( $frame['args'] ) ) {
continue;
}
foreach ( $frame['args'] as $arg ) {
$redacted = MWExceptionHandler::getRedactedTrace( $e );
foreach ( $redacted as $frame ) {
- if ( ! isset( $frame['args'] ) ) {
+ if ( !isset( $frame['args'] ) ) {
continue;
}
foreach ( $frame['args'] as $arg ) {
$file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
$this->assertEquals(
"Lorem ipsum \n1 \n",
- (string) $this->handler->getPageText( $file, 1 ),
+ (string)$this->handler->getPageText( $file, 1 ),
"Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"
);
}
array( 'Page/Another', 'Page/Another', 'en', 'es' ),
);
}
-}
\ No newline at end of file
+}
$media,
$file,
// XXX: Wrapped in an object to keep it out of PHPUnit output
- (object) array( 'cssText' => $readStyleFile->invoke( $module, $file, $flip ) ),
+ (object)array( 'cssText' => $readStyleFile->invoke( $module, $file, $flip ) ),
);
}
}
$this->test = array(
'test' => ParserTest::chomp( $this->sectionData['test'] ),
- 'input' => ParserTest::chomp( $this->sectionData[ $input ] ),
- 'result' => ParserTest::chomp( $this->sectionData[ $result ] ),
+ 'input' => ParserTest::chomp( $this->sectionData[$input] ),
+ 'result' => ParserTest::chomp( $this->sectionData[$result] ),
'options' => ParserTest::chomp( $this->sectionData['options'] ),
'config' => ParserTest::chomp( $this->sectionData['config'] ),
);
$data = $this->sectionData;
$tokens = array_filter( $tokens, function ( $token ) use ( $data ) {
- return isset( $data[ $token ] );
+ return isset( $data[$token] );
} );
if ( count( $tokens ) == 0 ) {
}
$tokens = array_values( $tokens );
- return $tokens[ 0 ];
+ return $tokens[0];
}
}