Just another 80 or so PHPStorm inspection fixes (#4)
* Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
This commit is contained in:
parent
317b460500
commit
be3018b268
61 changed files with 51 additions and 94 deletions
|
|
@ -1406,7 +1406,7 @@ MESSAGE;
|
|||
}
|
||||
|
||||
private static function isEmptyObject( stdClass $obj ) {
|
||||
foreach ( $obj as $key => $value ) {
|
||||
foreach ( $obj as $value ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class ReflectionSchemaSource implements SettingsSource {
|
|||
}
|
||||
|
||||
private function normalizeComment( string $doc ) {
|
||||
$doc = preg_replace( '/^\s*\/\*+\s*|\s*\*+\/\s*$/s', '', $doc );
|
||||
$doc = preg_replace( '/^\s*\/\*+\s*|\s*\*+\/\s*$/', '', $doc );
|
||||
$doc = preg_replace( '/^\s*\**$/m', " ", $doc );
|
||||
$doc = preg_replace( '/^\s*\**[ \t]?/m', '', $doc );
|
||||
return $doc;
|
||||
|
|
|
|||
|
|
@ -1348,8 +1348,7 @@ class WebRequest {
|
|||
*/
|
||||
public static function canonicalizeIPv6LoopbackAddress( $ip ) {
|
||||
// Code moved from IPUtils library. See T248237#6614927
|
||||
$m = [];
|
||||
if ( preg_match( '/^0*' . IPUtils::RE_IPV6_GAP . '1$/', $ip, $m ) ) {
|
||||
if ( preg_match( '/^0*' . IPUtils::RE_IPV6_GAP . '1$/', $ip ) ) {
|
||||
return '127.0.0.1';
|
||||
}
|
||||
return $ip;
|
||||
|
|
|
|||
|
|
@ -383,7 +383,6 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
$classes = [];
|
||||
|
||||
$del = '';
|
||||
$user = $this->getUser();
|
||||
$canRevDelete = $this->getAuthority()->isAllowed( 'deleterevision' );
|
||||
// Show checkboxes for each revision, to allow for revision deletion and
|
||||
// change tags
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class WikiTextStructure {
|
|||
$heading = preg_replace( '/<\/?span>/', '', $heading );
|
||||
// Normalize [] so the following regexp would work.
|
||||
$heading = preg_replace( [ '/[/', '/]/' ], [ '[', ']' ], $heading );
|
||||
$heading = preg_replace( '/<sup>\s*\[\s*\d+\s*\]\s*<\/sup>/is', '', $heading );
|
||||
$heading = preg_replace( '/<sup>\s*\[\s*\d+\s*\]\s*<\/sup>/i', '', $heading );
|
||||
|
||||
// Strip tags from the heading or else we'll display them (escaped) in search results
|
||||
$heading = trim( Sanitizer::stripAllTags( $heading ) );
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class SearchUpdate implements DeferrableUpdate {
|
|||
# Strip HTML markup
|
||||
$text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
|
||||
' ', $contLang->lc( " " . $text . " " ) );
|
||||
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
|
||||
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/",
|
||||
"\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
|
||||
|
||||
# Strip external URLs
|
||||
|
|
|
|||
|
|
@ -1581,7 +1581,7 @@ abstract class Installer {
|
|||
}
|
||||
|
||||
// phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
|
||||
global $wgAutoloadClasses, $wgExtensionDirectory, $wgStyleDirectory;
|
||||
global $wgExtensionDirectory, $wgStyleDirectory;
|
||||
$wgExtensionDirectory = "$IP/extensions";
|
||||
$wgStyleDirectory = "$IP/skins";
|
||||
|
||||
|
|
|
|||
|
|
@ -1047,7 +1047,7 @@ EOF;
|
|||
* @return bool True if $text appears to be written in $variant
|
||||
*/
|
||||
public function guessVariant( $text, $variant ) {
|
||||
$hasBalinese = preg_match( "/[\x{1B00}-\x{1B7F}]/u", $text, $dummy );
|
||||
$hasBalinese = preg_match( "/[\x{1B00}-\x{1B7F}]/u", $text );
|
||||
return ( $variant == 'ban-bali' ) == $hasBalinese;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class LanguageCu extends Language {
|
|||
# join and array_slice instead mb_substr
|
||||
$ar = [];
|
||||
preg_match_all( '/./us', $word, $ar );
|
||||
if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
|
||||
if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) {
|
||||
switch ( $case ) {
|
||||
case 'genitive': # родительный падеж
|
||||
if ( ( implode( '', array_slice( $ar[0], -4 ) ) == 'вики' )
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class LanguageHy extends Language {
|
|||
# join and array_slice instead mb_substr
|
||||
$ar = [];
|
||||
preg_match_all( '/./us', $word, $ar );
|
||||
if ( !preg_match( "/[a-zA-Z_]/us", $word ) ) {
|
||||
if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) {
|
||||
switch ( $case ) {
|
||||
case 'genitive': # սեռական հոլով
|
||||
if ( implode( '', array_slice( $ar[0], -1 ) ) == 'ա' ) {
|
||||
|
|
|
|||
|
|
@ -275,8 +275,6 @@ class RedisBagOStuff extends MediumSpecificBagOStuff {
|
|||
}
|
||||
|
||||
protected function doDeleteMulti( array $keys, $flags = 0 ) {
|
||||
$result = true;
|
||||
|
||||
[ $keysByServer, $connByServer, $result ] = $this->getConnectionsForKeys( $keys );
|
||||
foreach ( $keysByServer as $server => $batchKeys ) {
|
||||
$conn = $connByServer[$server];
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ class GeneralizedSql {
|
|||
|
||||
# All numbers => N,
|
||||
# except the ones surrounded by characters, e.g. l10n
|
||||
$sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
|
||||
$sql = preg_replace( '/(?<![a-zA-Z])-?\d+(?![a-zA-Z])/s', 'N', $sql );
|
||||
$sql = preg_replace( '/-?\d+(,-?\d+)+/', 'N,...,N', $sql );
|
||||
$sql = preg_replace( '/(?<![a-zA-Z])-?\d+(?![a-zA-Z])/', 'N', $sql );
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -467,7 +467,6 @@ class Linker {
|
|||
|
||||
if ( !$thumb ) {
|
||||
$rdfaType = 'mw:Error ' . $rdfaType;
|
||||
$label = '';
|
||||
if ( $enableLegacyMediaDOM ) {
|
||||
$label = $frameParams['title'];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ class CoreMagicVariables {
|
|||
LoggerInterface $logger
|
||||
): ?string {
|
||||
$pageLang = $parser->getTargetLanguage();
|
||||
$title = $parser->getTitle();
|
||||
|
||||
switch ( $id ) {
|
||||
case '!':
|
||||
|
|
|
|||
|
|
@ -5545,7 +5545,7 @@ class Parser {
|
|||
if ( $value === '' ) {
|
||||
$type = 'no-link';
|
||||
} elseif ( preg_match( "/^((?i)$prots)/", $value ) ) {
|
||||
if ( preg_match( "/^((?i)$prots)$addr$chars*$/u", $value, $m ) ) {
|
||||
if ( preg_match( "/^((?i)$prots)$addr$chars*$/u", $value ) ) {
|
||||
$this->mOutput->addExternalLink( $value );
|
||||
$type = 'link-url';
|
||||
$target = $value;
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ class SkinComponentListItem implements SkinComponent {
|
|||
if ( isset( $item['itemtitle'] ) ) {
|
||||
$attrs['title'] = $item['itemtitle'];
|
||||
}
|
||||
$tag = $this->options['tag'] ?? 'li';
|
||||
// Making sure we always have strings as class values
|
||||
$classes = is_array( $attrs['class'] ) ?
|
||||
implode( ' ', $attrs['class'] ) :
|
||||
|
|
|
|||
|
|
@ -1374,21 +1374,21 @@ abstract class UploadBase {
|
|||
$chunk = Sanitizer::decodeCharReferences( $chunk );
|
||||
|
||||
# look for script-types
|
||||
if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) {
|
||||
if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!im', $chunk ) ) {
|
||||
wfDebug( __METHOD__ . ": found script types" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
# look for html-style script-urls
|
||||
if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
|
||||
if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!im', $chunk ) ) {
|
||||
wfDebug( __METHOD__ . ": found html-style script urls" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
# look for css-style script-urls
|
||||
if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
|
||||
if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!im', $chunk ) ) {
|
||||
wfDebug( __METHOD__ . ": found css-style script urls" );
|
||||
|
||||
return true;
|
||||
|
|
@ -1420,7 +1420,7 @@ abstract class UploadBase {
|
|||
|
||||
return true;
|
||||
}
|
||||
} elseif ( preg_match( "!<\?xml\b!si", $contents ) ) {
|
||||
} elseif ( preg_match( "!<\?xml\b!i", $contents ) ) {
|
||||
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
|
||||
// bytes. There shouldn't be a legitimate reason for this to happen.
|
||||
wfDebug( __METHOD__ . ": Unmatched XML declaration start" );
|
||||
|
|
@ -1448,7 +1448,7 @@ abstract class UploadBase {
|
|||
|
||||
return true;
|
||||
}
|
||||
} elseif ( $str != '' && preg_match( "!<\?xml\b!si", $str ) ) {
|
||||
} elseif ( $str != '' && preg_match( "!<\?xml\b!i", $str ) ) {
|
||||
// Start of XML declaration without an end in the first $wgSVGMetadataCutoff
|
||||
// bytes. There shouldn't be a legitimate reason for this to happen.
|
||||
wfDebug( __METHOD__ . ": Unmatched XML declaration start" );
|
||||
|
|
@ -1729,7 +1729,7 @@ abstract class UploadBase {
|
|||
# use set to add a remote / data / script target to an element
|
||||
if ( $strippedElement === 'set'
|
||||
&& $stripped === 'to'
|
||||
&& preg_match( '!(http|https|data|script):!sim', $value )
|
||||
&& preg_match( '!(http|https|data|script):!im', $value )
|
||||
) {
|
||||
wfDebug( __METHOD__ . ": Found svg setting attribute to '$value' in uploaded file." );
|
||||
|
||||
|
|
@ -1737,7 +1737,7 @@ abstract class UploadBase {
|
|||
}
|
||||
|
||||
# use handler attribute with remote / data / script
|
||||
if ( $stripped === 'handler' && preg_match( '!(http|https|data|script):!sim', $value ) ) {
|
||||
if ( $stripped === 'handler' && preg_match( '!(http|https|data|script):!im', $value ) ) {
|
||||
wfDebug( __METHOD__ . ": Found svg setting handler with remote/data/script "
|
||||
. "'$attrib'='$value' in uploaded file." );
|
||||
|
||||
|
|
@ -1768,7 +1768,7 @@ abstract class UploadBase {
|
|||
# Only allow url( "#foo" ). Do not allow url( http://example.com )
|
||||
if ( $strippedElement === 'image'
|
||||
&& $stripped === 'filter'
|
||||
&& preg_match( '!url\s*\(\s*["\']?[^#]!sim', $value )
|
||||
&& preg_match( '!url\s*\(\s*["\']?[^#]!im', $value )
|
||||
) {
|
||||
wfDebug( __METHOD__ . ": Found image filter with url: "
|
||||
. "\"<$strippedElement $stripped='$value'...\" in uploaded file." );
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ class CleanupSpam extends Maintenance {
|
|||
->where( $conds )
|
||||
->caller( __METHOD__ )
|
||||
->fetchResultSet();
|
||||
$count = $res->numRows();
|
||||
$this->output( "Found $count articles containing $spec\n" );
|
||||
$count += $res->numRows();
|
||||
$this->output( "Found $count articles containing $spec so far...\n" );
|
||||
foreach ( $res as $row ) {
|
||||
$this->cleanupArticle(
|
||||
$row->el_from,
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ class MWDoxygenFilter {
|
|||
// wrongly interpreted as a Doxygen "\command".
|
||||
$content = addcslashes( $content, '\\' );
|
||||
// Look for instances of "@var SomeType".
|
||||
if ( preg_match( '#@var\s+\S+#s', $content ) ) {
|
||||
if ( preg_match( '#@var\s+\S+#', $content ) ) {
|
||||
$buffer = [ 'raw' => $content, 'desc' => null, 'type' => null, 'name' => null ];
|
||||
$buffer['desc'] = preg_replace_callback(
|
||||
// Strip "@var SomeType" part, but remember the type and optional name
|
||||
'#@var\s+(\S+)(\s+)?(\S+)?#s',
|
||||
'#@var\s+(\S+)(\s+)?(\S+)?#',
|
||||
static function ( $matches ) use ( &$buffer ) {
|
||||
$buffer['type'] = $matches[1];
|
||||
$buffer['name'] = $matches[3] ?? null;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class GenerateCollationData extends Maintenance {
|
|||
|
||||
public $debugOutFile;
|
||||
|
||||
private $groups;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addOption( 'data-dir', 'A directory on the local filesystem ' .
|
||||
|
|
|
|||
|
|
@ -623,8 +623,6 @@ class CommentStoreTest extends MediaWikiLangTestCase {
|
|||
}
|
||||
|
||||
public static function provideInsertRoundTrip() {
|
||||
$db = wfGetDB( DB_REPLICA ); // for timestamps
|
||||
|
||||
$msgComment = new Message( 'parentheses', [ 'message comment' ] );
|
||||
$textCommentMsg = new RawMessage( '$1', [ Message::plaintextParam( '{{text}} comment' ) ] );
|
||||
$nestedMsgComment = new Message( [ 'parentheses', 'rawmessage' ], [ new Message( 'mainpage' ) ] );
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ class ExtraParserTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers Parser::cleanSig
|
||||
*/
|
||||
public function testCleanSig() {
|
||||
$title = Title::newFromText( __FUNCTION__ );
|
||||
$outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
|
||||
|
||||
$this->assertEquals( "{{SUBST:Foo}} ", $outputText );
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ class GlobalTest extends MediaWikiIntegrationTestCase {
|
|||
$this->markTestSkippedIfNoDiff3();
|
||||
|
||||
$mergedText = null;
|
||||
$attemptMergeResult = null;
|
||||
$mergeAttemptResult = null;
|
||||
$isMerged = wfMerge( $old, $mine, $yours, $mergedText, $mergeAttemptResult );
|
||||
|
||||
$msg = 'Merge should be a ';
|
||||
|
|
|
|||
|
|
@ -1406,7 +1406,6 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// We don't reset the categories, for some reason, only the links
|
||||
$expectedNormalCats = array_merge( [ 'Initial page' ], $expectedNormal );
|
||||
$expectedCats = array_merge( $expectedHidden, $expectedNormalCats );
|
||||
|
||||
$this->doCategoryAsserts( $op, $expectedNormalCats, $expectedHidden );
|
||||
$this->doCategoryLinkAsserts( $op, $expectedNormal, $expectedHidden );
|
||||
|
|
|
|||
|
|
@ -939,12 +939,12 @@ END
|
|||
'startup response undisrupted (T152266)'
|
||||
);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/register\([^)]+"ferry",\s*""/s',
|
||||
'/register\([^)]+"ferry",\s*""/',
|
||||
$response,
|
||||
'startup response registers broken module'
|
||||
);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/state\([^)]+"ferry":\s*"error"/s',
|
||||
'/state\([^)]+"ferry":\s*"error"/',
|
||||
$response,
|
||||
'startup response sets state to error'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ class ApiBlockTest extends ApiTestCase {
|
|||
|
||||
public function testBlockWithRestrictionsPage() {
|
||||
$title = 'Foo';
|
||||
$page = $this->getExistingTestPage( $title );
|
||||
$this->getExistingTestPage( $title );
|
||||
|
||||
$this->doBlock( [
|
||||
'partial' => true,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class ApiDeleteTest extends ApiTestCase {
|
|||
// test deletion without permission
|
||||
try {
|
||||
$user = new User();
|
||||
$apiResult = $this->doApiRequest( [
|
||||
$this->doApiRequest( [
|
||||
'action' => 'delete',
|
||||
'title' => $name,
|
||||
'token' => $user->getEditToken(),
|
||||
|
|
|
|||
|
|
@ -892,7 +892,6 @@ class ApiEditPageTest extends ApiTestCase {
|
|||
// to insert new revision rows at once and the first one to succeed
|
||||
// gets rolled back.
|
||||
$name = 'Help:' . ucfirst( __FUNCTION__ );
|
||||
$titleObj = Title::newFromText( $name );
|
||||
|
||||
$revId1 = $this->editPage( $name, '1' )->getNewRevision()->getId();
|
||||
$revId2 = $this->editPage( $name, '2' )->getNewRevision()->getId();
|
||||
|
|
|
|||
|
|
@ -403,7 +403,6 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
$aboutpage = wfMessage( 'aboutpage' );
|
||||
$mainpage = wfMessage( 'mainpage' );
|
||||
$parens = wfMessage( 'parentheses', 'foobar' );
|
||||
$brackets = wfMessage( 'brackets', 'foobar' );
|
||||
$copyright = wfMessage( 'copyright' );
|
||||
$disclaimers = wfMessage( 'disclaimers' );
|
||||
$edithelp = wfMessage( 'edithelp' );
|
||||
|
|
|
|||
|
|
@ -96,8 +96,6 @@ class ApiPageSetTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testRedirectMergePolicyRedirectLoop() {
|
||||
$loopA = Title::makeTitle( NS_MAIN, 'UTPageRedirectOne' );
|
||||
$loopB = Title::makeTitle( NS_MAIN, 'UTPageRedirectTwo' );
|
||||
$this->editPage( 'UTPageRedirectOne', '#REDIRECT [[UTPageRedirectTwo]]' );
|
||||
$this->editPage( 'UTPageRedirectTwo', '#REDIRECT [[UTPageRedirectOne]]' );
|
||||
[ $target, $pageSet ] = $this->createPageSetWithRedirect(
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ class ApiParseTest extends ApiTestCase {
|
|||
protected static $revIds = [];
|
||||
|
||||
public function addDBDataOnce() {
|
||||
$title = Title::newFromText( __CLASS__ );
|
||||
|
||||
$status = $this->editPage( __CLASS__, 'Test for revdel' );
|
||||
self::$pageId = $status->getNewRevision()->getPageId();
|
||||
self::$revIds['revdel'] = $status->getNewRevision()->getId();
|
||||
|
|
@ -110,7 +108,7 @@ class ApiParseTest extends ApiTestCase {
|
|||
$this->assertSame( $expectedEnd, substr( $html, -strlen( $expectedEnd ) ) );
|
||||
|
||||
$unexpectedEnd = '#<!-- \nNewPP limit report|' .
|
||||
'<!--\nTransclusion expansion time report#s';
|
||||
'<!--\nTransclusion expansion time report#';
|
||||
$this->assertDoesNotMatchRegularExpression( $unexpectedEnd, $html );
|
||||
|
||||
$html = substr( $html, 0, strlen( $html ) - strlen( $expectedEnd ) );
|
||||
|
|
|
|||
|
|
@ -353,7 +353,6 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
if ( $val['name'] === 'viscount' ) {
|
||||
$viscountFound = true;
|
||||
$this->assertSame( [ 'perambulate' ], $val['rights'] );
|
||||
$this->assertSame( $userAllGroups, $val['add'] );
|
||||
} elseif ( $val['name'] === 'bot' ) {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ class AbstractPrimaryAuthenticationProviderTest extends \MediaWikiIntegrationTes
|
|||
} catch ( \BadMethodCallException $ex ) {
|
||||
}
|
||||
|
||||
$req = $this->getMockForAbstractClass( AuthenticationRequest::class );
|
||||
|
||||
$this->assertTrue( $provider->providerAllowsPropertyChange( 'foo' ) );
|
||||
$this->assertEquals(
|
||||
\StatusValue::newGood(),
|
||||
|
|
|
|||
|
|
@ -1144,7 +1144,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
AuthManagerLoginAuthenticateAuditHook::class, $this->never() );
|
||||
}
|
||||
|
||||
$ex = null;
|
||||
try {
|
||||
if ( !$i ) {
|
||||
$ret = $this->manager->beginAuthentication( [ $req ], 'http://localhost/' );
|
||||
|
|
@ -2259,7 +2258,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->hook( 'LocalUserCreated', LocalUserCreatedHook::class, $this->never() );
|
||||
}
|
||||
|
||||
$ex = null;
|
||||
try {
|
||||
if ( $first ) {
|
||||
$userReq = new UsernameAuthenticationRequest;
|
||||
|
|
@ -3096,7 +3094,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->willReturn( $good );
|
||||
}
|
||||
|
||||
$primaries = [];
|
||||
foreach ( [
|
||||
PrimaryAuthenticationProvider::TYPE_NONE,
|
||||
PrimaryAuthenticationProvider::TYPE_CREATE,
|
||||
|
|
@ -3276,8 +3273,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
return $ret;
|
||||
};
|
||||
|
||||
$good = StatusValue::newGood();
|
||||
|
||||
$primary1 = $this->createMock( AbstractPrimaryAuthenticationProvider::class );
|
||||
$primary1->method( 'getUniqueId' )
|
||||
->willReturn( 'primary1' );
|
||||
|
|
@ -3706,7 +3701,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
$first = true;
|
||||
$created = false;
|
||||
$expectLog = [];
|
||||
foreach ( $managerResponses as $i => $response ) {
|
||||
if ( $response instanceof AuthenticationResponse &&
|
||||
|
|
@ -3715,7 +3709,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$expectLog[] = [ LogLevel::INFO, 'Account linked to {user} by primary' ];
|
||||
}
|
||||
|
||||
$ex = null;
|
||||
try {
|
||||
if ( $first ) {
|
||||
$ret = $this->manager->beginAccountLink( $user, [ $req ], 'http://localhost/' );
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ class AuthenticationRequestTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$fields = AuthenticationRequest::mergeFieldInfo( [ $req1 ] );
|
||||
$expect = $req1->getFieldInfo();
|
||||
foreach ( $expect as $name => &$options ) {
|
||||
foreach ( $expect as &$options ) {
|
||||
$options['optional'] = !empty( $options['optional'] );
|
||||
$options['sensitive'] = !empty( $options['sensitive'] );
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ class AuthenticationRequestTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$fields = AuthenticationRequest::mergeFieldInfo( [ $req1, $req2 ] );
|
||||
$expect = $req1->getFieldInfo() + $req2->getFieldInfo();
|
||||
foreach ( $expect as $name => &$options ) {
|
||||
foreach ( $expect as &$options ) {
|
||||
$options['sensitive'] = !empty( $options['sensitive'] );
|
||||
}
|
||||
$expect['string1']['optional'] = false;
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
] );
|
||||
$this->assertEquals(
|
||||
AuthenticationResponse::newPass(),
|
||||
$res = $provider->continueLinkAttempt( $user, 'state', [ $req ] )
|
||||
$provider->continueLinkAttempt( $user, 'state', [ $req ] )
|
||||
);
|
||||
$this->assertSame( [ false, false, false ], $done );
|
||||
|
||||
|
|
|
|||
|
|
@ -673,10 +673,6 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
$expect->createRequest->username = 'Foo';
|
||||
$this->assertEquals( $expect, $provider->beginPrimaryAccountCreation( $user, $user, $reqs ) );
|
||||
|
||||
// We have to cheat a bit to avoid having to add a new user to
|
||||
// the database to test the actual setting of the password works right
|
||||
$dbw = wfGetDB( DB_PRIMARY );
|
||||
|
||||
$user = \User::newFromName( 'UTSysop' );
|
||||
$req->username = $user->getName();
|
||||
$req->password = 'NewPassword';
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ just a test"
|
|||
"0",
|
||||
"No more",
|
||||
null,
|
||||
trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
|
||||
trim( preg_replace( '/^Intro/m', 'No more', self::$sections ) )
|
||||
],
|
||||
[ self::$sections,
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class FileTest extends MediaWikiMediaTestCase {
|
|||
$reflection_property->setValue( $fileMock, $handlerMock );
|
||||
|
||||
if ( $data['tmpBucketedThumbCache'] !== null ) {
|
||||
foreach ( $data['tmpBucketedThumbCache'] as $bucket => &$tmpBucketed ) {
|
||||
foreach ( $data['tmpBucketedThumbCache'] as &$tmpBucketed ) {
|
||||
$tmpBucketed = str_replace( '/tmp', $tempDir, $tmpBucketed );
|
||||
}
|
||||
$reflection_property = $reflection->getProperty( 'tmpBucketedThumbCache' );
|
||||
|
|
|
|||
|
|
@ -189,7 +189,6 @@ class GuzzleHttpRequestTest extends MediaWikiIntegrationTestCase {
|
|||
$history = Middleware::history( $container );
|
||||
$stack = HandlerStack::create( new MockHandler( [ new Response() ] ) );
|
||||
$stack->push( $history );
|
||||
$boundary = 'boundary';
|
||||
$client = new GuzzleHttpRequest( $this->exampleUrl, [
|
||||
'method' => 'POST',
|
||||
'handler' => $stack,
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class ImportExportTest extends MediaWikiLangTestCase {
|
|||
|
||||
$n = 1;
|
||||
$revisions = $this->getRevisions( $title );
|
||||
foreach ( $revisions as $i => $rev ) {
|
||||
foreach ( $revisions as $rev ) {
|
||||
$revkey = "{$name}_rev" . $n++;
|
||||
|
||||
$vars[ $revkey . '_id' ] = $rev->getId();
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ abstract class GenericArrayObjectTest extends PHPUnit\Framework\TestCase {
|
|||
* @param callable $function
|
||||
*/
|
||||
protected function checkTypeChecks( $function ) {
|
||||
$excption = null;
|
||||
$list = $this->getNew();
|
||||
|
||||
$elementClass = $list->getObjectType();
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ class JpegTest extends MediaWikiMediaTestCase {
|
|||
|
||||
copy( $sourceFilepath, $filepath );
|
||||
|
||||
$file = $this->dataFile( $sourceFilename, 'image/jpeg' );
|
||||
$this->handler->swapICCProfile(
|
||||
$filepath,
|
||||
[ 'sRGB', '-' ],
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
||||
$html = trim( preg_replace( '/[\r\n]{2,}/s', "\n", $html ) );
|
||||
$html = trim( preg_replace( '/\s{2,}/s', ' ', $html ) );
|
||||
$html = trim( preg_replace( '/[\r\n]{2,}/', "\n", $html ) );
|
||||
$html = trim( preg_replace( '/\s{2,}/', ' ', $html ) );
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1121,7 +1121,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
$text = $po->getText();
|
||||
|
||||
$text = trim( preg_replace( '/<!--.*?-->/sm', '', $text ) ); # strip injected comments
|
||||
$text = preg_replace( '!\s*(</p>|</div>)!sm', '\1', $text ); # don't let tidy confuse us
|
||||
$text = preg_replace( '!\s*(</p>|</div>)!m', '\1', $text ); # don't let tidy confuse us
|
||||
|
||||
$this->assertEquals( $expectedHtml, $text );
|
||||
}
|
||||
|
|
@ -1175,7 +1175,7 @@ more stuff
|
|||
"0",
|
||||
"No more",
|
||||
null,
|
||||
trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
|
||||
trim( preg_replace( '/^Intro/m', 'No more', self::$sections ) )
|
||||
],
|
||||
[ 'Help:WikiPageTest_testReplaceSection',
|
||||
CONTENT_MODEL_WIKITEXT,
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
|
|||
}
|
||||
|
||||
private function mockSearchWithResults( $titleStrings, $limit = 3 ) {
|
||||
$search = $stub = $this->getMockBuilder( SearchEngine::class )
|
||||
$search = $this->getMockBuilder( SearchEngine::class )
|
||||
->onlyMethods( [ 'completionSearchBackend' ] )->getMock();
|
||||
|
||||
$return = SearchSuggestionSet::fromStrings( $titleStrings );
|
||||
|
|
|
|||
|
|
@ -471,7 +471,6 @@ class CookieSessionProviderTest extends MediaWikiIntegrationTestCase {
|
|||
$backend->setRememberUser( true );
|
||||
$backend->setForceHTTPS( true );
|
||||
$request = new \MediaWiki\Request\FauxRequest();
|
||||
$time = time();
|
||||
$provider->persistSession( $backend, $request );
|
||||
$this->assertSame( $sessionId, $request->response()->getCookie( 'MySessionName' ) );
|
||||
$this->assertSame( (string)$user->getId(), $request->response()->getCookie( 'xUserID' ) );
|
||||
|
|
|
|||
|
|
@ -439,7 +439,6 @@ class SessionManagerTest extends MediaWikiIntegrationTestCase {
|
|||
public function testGetEmptySession() {
|
||||
$manager = $this->getManager();
|
||||
$pmanager = TestingAccessWrapper::newFromObject( $manager );
|
||||
$request = new \MediaWiki\Request\FauxRequest();
|
||||
|
||||
$providerBuilder = $this->getMockBuilder( \DummySessionProvider::class )
|
||||
->onlyMethods( [ 'provideSessionInfo', 'newSessionInfo', '__toString' ] );
|
||||
|
|
|
|||
|
|
@ -289,7 +289,6 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$this->assertObjectNotHasAttribute( 'ipb_restrictions', $row );
|
||||
|
||||
$pageName = 'Victor Frankenstein';
|
||||
$page = $this->getExistingTestPage( 'Victor Frankenstein' );
|
||||
$title = $page->getTitle();
|
||||
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
|
|||
);
|
||||
|
||||
$m = $this->getMigration( $stage );
|
||||
$result = $m->getWhere( $this->db, 'am1_user', 'Foo' );
|
||||
$m->getWhere( $this->db, 'am1_user', 'Foo' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@ class BotPasswordTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertEquals( '{"IPAddresses":["127.0.0.0/8"]}', $bp->getRestrictions()->toJson() );
|
||||
$this->assertSame( [ 'test' ], $bp->getGrants() );
|
||||
|
||||
$user = $this->testUser->getUser();
|
||||
$bp = BotPassword::newUnsaved( [
|
||||
'centralId' => 45,
|
||||
'appId' => 'DoesNotExist'
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ class ParsoidOutputAccessTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
||||
$html = trim( preg_replace( '/[\r\n]{2,}/s', "\n", $html ) );
|
||||
$html = trim( preg_replace( '/\s{2,}/s', ' ', $html ) );
|
||||
$html = trim( preg_replace( '/[\r\n]{2,}/', "\n", $html ) );
|
||||
$html = trim( preg_replace( '/\s{2,}/', ' ', $html ) );
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
|
|||
$targetToken = $userFactory->newFromUserIdentity( $block->getTargetUserIdentity() )->getToken();
|
||||
|
||||
$store = $this->getStore( $options );
|
||||
$result = $store->insertBlock( $block );
|
||||
$store->insertBlock( $block );
|
||||
|
||||
$this->assertSame(
|
||||
$expectTokenEqual,
|
||||
|
|
|
|||
|
|
@ -222,8 +222,6 @@ class PoolCounterWorkTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers ::execute
|
||||
*/
|
||||
public function testDoWorkRaiseException() {
|
||||
$workerResults = 'SomeStringForResult';
|
||||
|
||||
$worker = $this->configureFixture(
|
||||
[ 'doWork' => $this->throwException( new MWException() ) ],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -678,7 +678,7 @@ class DumpAsserter {
|
|||
*/
|
||||
public function stripTestTags( $text ) {
|
||||
$text = preg_replace( '@<!--.*?-->@s', '', $text );
|
||||
$text = preg_replace( '@</?test:[^>]+>@s', '', $text );
|
||||
$text = preg_replace( '@</?test:[^>]+>@', '', $text );
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ class TextPassDumperDatabaseTest extends DumpTestCase {
|
|||
// Setting up of the dump
|
||||
$nameStub = $this->setUpStub( 'AllStubs', $wgXmlDumpSchemaVersion );
|
||||
$nameFull = $this->getNewTempFile();
|
||||
$expFile = $this->getDumpTemplatePath( 'AllText', $wgXmlDumpSchemaVersion );
|
||||
|
||||
$dumper = new TextPassDumper( [ "--stub=file:" . $nameStub,
|
||||
"--output=file:" . $nameFull ] );
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class ParsoidTestFileSuite extends TestSuite {
|
|||
}
|
||||
$testModes = $t->computeTestModes( $validTestModes );
|
||||
$t->testAllModes( $testModes, $runner->getOptions(),
|
||||
// $options is being ignored but it is identical to $runnerOpts
|
||||
// $options is being ignored but it is identical to $runner->getOptions()
|
||||
function ( ParserTest $test, string $modeStr, array $options ) use (
|
||||
$t, $suite, $fileName, $skipMessage
|
||||
) {
|
||||
|
|
@ -72,7 +72,6 @@ class ParsoidTestFileSuite extends TestSuite {
|
|||
// Ensure that updates to knownFailures in $test are reflected in $t
|
||||
$test->knownFailures = &$t->knownFailures;
|
||||
$runner = $this->ptRunner;
|
||||
$runnerOpts = $runner->getOptions();
|
||||
$mode = new ParserTestMode( $modeStr, $test->changetree );
|
||||
$pit = new ParserIntegrationTest( $runner, $fileName, $test, $mode, $skipMessage );
|
||||
$suite->addTest( $pit, [ 'Database', 'Parser', 'ParserTests' ] );
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ class FileSourceTest extends TestCase {
|
|||
|
||||
public function testLoad() {
|
||||
$source = new FileSource( __DIR__ . '/fixtures/settings.json' );
|
||||
$settings = $source->load();
|
||||
|
||||
$this->assertSame(
|
||||
[ 'config' => [ 'MySetting' => 'BlaBla' ] ],
|
||||
|
|
@ -28,7 +27,6 @@ class FileSourceTest extends TestCase {
|
|||
|
||||
public function testLoadFormat() {
|
||||
$source = new FileSource( __DIR__ . '/fixtures/settings.json', new JsonFormat() );
|
||||
$settings = $source->load();
|
||||
|
||||
$this->assertSame(
|
||||
[ 'config' => [ 'MySetting' => 'BlaBla' ] ],
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ChangesListFilterTest extends MediaWikiUnitTestCase {
|
|||
$this->expectExceptionMessage(
|
||||
"Filter names may not contain '_'. Use the naming convention: 'lowercase'"
|
||||
);
|
||||
$filter = new MockChangesListFilter(
|
||||
new MockChangesListFilter(
|
||||
[
|
||||
'group' => $this->group,
|
||||
'name' => 'some_name',
|
||||
|
|
|
|||
|
|
@ -612,7 +612,6 @@ class DatabaseTest extends PHPUnit\Framework\TestCase {
|
|||
$this->assertEquals( $ud->getId(), $this->db->getDomainID() );
|
||||
|
||||
$oldDomain = $this->db->getDomainID();
|
||||
$oldDbName = $this->db->getDBname();
|
||||
$oldSchema = $this->db->dbSchema();
|
||||
$oldPrefix = $this->db->tablePrefix();
|
||||
$this->assertIsString( $oldDomain, 'DB domain is string' );
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ function wfProxyThumbnailRequest( $img, $thumbName ) {
|
|||
}
|
||||
|
||||
// Send request to proxied service
|
||||
$status = $req->execute();
|
||||
$req->execute();
|
||||
|
||||
\MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue