// array() (a match with no data) but our WebRequest caller
// expects array() even when we have no matches so return
// a array() when we have null
- return is_null( $matches ) ? [] : $matches;
+ return $matches ?? [];
}
/**
case 'json':
return CONTENT_MODEL_JSON;
default:
- return is_null( $model ) ? CONTENT_MODEL_TEXT : $model;
+ return $model ?? CONTENT_MODEL_TEXT;
}
}
public function canUseNoindex() {
global $wgExemptFromUserRobotsControl;
- $bannedNamespaces = is_null( $wgExemptFromUserRobotsControl )
- ? MWNamespace::getContentNamespaces()
- : $wgExemptFromUserRobotsControl;
+ $bannedNamespaces = $wgExemptFromUserRobotsControl ?? MWNamespace::getContentNamespaces();
return !in_array( $this->mNamespace, $bannedNamespaces );
}
*/
private function formatSummary( $title, $params ) {
global $wgParser;
- $summary = !is_null( $params['summary'] ) ? $params['summary'] : '';
- $sectionTitle = !is_null( $params['sectiontitle'] ) ? $params['sectiontitle'] : '';
+ $summary = $params['summary'] ?? '';
+ $sectionTitle = $params['sectiontitle'] ?? '';
if ( $this->section === 'new' && ( $sectionTitle === '' || $summary === '' ) ) {
if ( $sectionTitle !== '' ) {
* @return array
*/
public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
- $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
+ if ( !$user ) {
+ $user = $this->getContext()->getUser();
+ }
+
return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
}
* @return array
*/
public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
- $guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
+ if ( !$guser ) {
+ $guser = $this->getContext()->getUser();
+ }
+
return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
}
// Avoid PHP 7.1 warning of passing $this by reference
$wikiPage = $this;
- $deleter = is_null( $deleter ) ? $wgUser : $deleter;
+ if ( !$deleter ) {
+ $deleter = $wgUser;
+ }
if ( !Hooks::run( 'ArticleDelete',
[ &$wikiPage, &$deleter, &$reason, &$error, &$status, $suppress ]
) ) {
$request = $this->getRequest();
$out->addModuleStyles( 'mediawiki.special' );
- $this->mTarget = is_null( $par )
- ? $request->getVal( 'wpTarget', $request->getVal( 'target', '' ) )
- : $par;
+ $this->mTarget = $par ?? $request->getVal( 'wpTarget', $request->getVal( 'target', '' ) );
// Make sure, that HTMLForm uses the correct target.
$request->setVal( 'wpTarget', $this->mTarget );
$this->outputHeader();
$request = $this->getRequest();
- $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
+ $target = $par ?? $request->getVal( 'target' );
// Yes, the use of getVal() and getText() is wanted, see T22365
$size = $request->getIntOrNull( 'size' );
$ns = $request->getIntOrNull( 'namespace' );
- $filters = $request->getArray( 'wpfilters' );
- $filters = is_null( $filters ) ? [] : $filters;
+ $filters = $request->getArray( 'wpfilters', [] );
$indefOnly = in_array( 'indefonly', $filters );
$cascadeOnly = in_array( 'cascadeonly', $filters );
$noRedirect = in_array( 'noredirect', $filters );
*/
public function testReplaceSection( $text, $section, $with, $sectionTitle, $expected ) {
$content = $this->newContent( $text );
+ /** @var WikitextContent $c */
$c = $content->replaceSection( $section, $this->newContent( $with ), $sectionTitle );
- $this->assertEquals( $expected, is_null( $c ) ? null : $c->getText() );
+ $this->assertEquals( $expected, $c ? $c->getText() : null );
}
/**
# now, test the actual redirect
$t = $page->getRedirectTarget();
- $this->assertEquals( $target, is_null( $t ) ? null : $t->getFullText() );
+ $this->assertEquals( $target, $t ? $t->getFullText() : null );
}
/**
$page = $this->createPage( $title, $text, $model );
$content = ContentHandler::makeContent( $with, $page->getTitle(), $page->getContentModel() );
+ /** @var TextContent $c */
$c = $page->replaceSectionContent( $section, $content, $sectionTitle );
- $this->assertEquals( $expected, is_null( $c ) ? null : trim( $c->getText() ) );
+ $this->assertEquals( $expected, $c ? trim( $c->getText() ) : null );
}
/**
$baseRevId = $page->getLatest();
$content = ContentHandler::makeContent( $with, $page->getTitle(), $page->getContentModel() );
+ /** @var TextContent $c */
$c = $page->replaceSectionAtRev( $section, $content, $sectionTitle, $baseRevId );
- $this->assertEquals( $expected, is_null( $c ) ? null : trim( $c->getText() ) );
+ $this->assertEquals( $expected, $c ? trim( $c->getText() ) : null );
}
/**