Replace trivial usages of code in strings with concatenation

This is really hard to read. What is code, what is string? These
places are so simple, they really don't need the "{$var}" syntax.

Change-Id: I589dedb8c0193eec4eef500bbb896b5b790b727b
This commit is contained in:
Thiemo Kreuz 2022-08-05 19:50:22 +02:00 committed by Thiemo Kreuz (WMDE)
parent 13f346fee2
commit 67c56155c7
13 changed files with 27 additions and 23 deletions

View file

@ -386,7 +386,7 @@ class DeferredUpdates {
JobQueueGroupFactory $jobQueueGroupFactory,
$httpMethod
): ?Throwable {
$suffix = ( $update instanceof DeferrableCallback ) ? "_{$update->getOrigin()}" : '';
$suffix = $update instanceof DeferrableCallback ? '_' . $update->getOrigin() : '';
$type = get_class( $update ) . $suffix;
$stats->increment( "deferred_updates.$httpMethod.$type" );
$updateId = spl_object_id( $update );

View file

@ -454,7 +454,7 @@ abstract class Job implements RunnableJob {
$s = $this->command;
if ( is_object( $this->title ) ) {
$s .= " {$this->title->getPrefixedDBkey()}";
$s .= ' ' . $this->title->getPrefixedDBkey();
}
if ( $paramString != '' ) {
$s .= " $paramString";

View file

@ -237,6 +237,6 @@ class Command extends UnboxedCommand {
* @return string
*/
public function __toString(): string {
return "#Command: {$this->getCommandString()}";
return '#Command: ' . $this->getCommandString();
}
}

View file

@ -1426,7 +1426,7 @@ abstract class Skin extends ContextSource {
if ( str_contains( $rootUser, $delimiter ) ) {
// Username contains interwiki delimiter, link it via the
// #{userid} syntax. (T260222)
$linkArgs = [ false, [ 'user' => "#{$user->getId()}" ] ];
$linkArgs = [ false, [ 'user' => '#' . $user->getId() ] ];
} else {
$linkArgs = [ $rootUser ];
}

View file

@ -68,22 +68,22 @@ class RefreshFileHeaders extends Maintenance {
$fileQuery = LocalFile::getQueryInfo();
do {
$conds = [ "img_name > {$dbr->addQuotes( $start )}" ];
$conds = [ 'img_name > ' . $dbr->addQuotes( $start ) ];
if ( strlen( $end ) ) {
$conds[] = "img_name <= {$dbr->addQuotes( $end )}";
$conds[] = 'img_name <= ' . $dbr->addQuotes( $end );
}
if ( strlen( $media_type ) ) {
$conds[] = "img_media_type = {$dbr->addQuotes( $media_type )}";
$conds['img_media_type'] = $media_type;
}
if ( strlen( $major_mime ) ) {
$conds[] = "img_major_mime = {$dbr->addQuotes( $major_mime )}";
$conds['img_major_mime'] = $major_mime;
}
if ( strlen( $minor_mime ) ) {
$conds[] = "img_minor_mime = {$dbr->addQuotes( $minor_mime )}";
$conds['img_minor_mime'] = $minor_mime;
}
$res = $dbr->select( $fileQuery['tables'],

View file

@ -405,11 +405,11 @@ class RefreshLinks extends Maintenance {
if ( $start === null && $end === null ) {
return "$var IS NOT NULL";
} elseif ( $end === null ) {
return "$var >= {$db->addQuotes( $start )}";
return "$var >= " . $db->addQuotes( $start );
} elseif ( $start === null ) {
return "$var <= {$db->addQuotes( $end )}";
return "$var <= " . $db->addQuotes( $end );
} else {
return "$var BETWEEN {$db->addQuotes( $start )} AND {$db->addQuotes( $end )}";
return "$var BETWEEN " . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end );
}
}

View file

@ -60,7 +60,7 @@ class DumpRenderer extends Maintenance {
$this->startTime = microtime( true );
if ( $this->hasOption( 'parser' ) ) {
$this->prefix .= "-{$this->getOption( 'parser' )}";
$this->prefix .= '-' . $this->getOption( 'parser' );
// T236809: We'll need to provide an alternate ParserFactory
// service to make this work.
$this->fatalError( 'Parser class configuration temporarily disabled.' );

View file

@ -65,7 +65,7 @@ class DatabaseTestHelper extends Database {
'queryLogger' => new NullLogger(),
'replLogger' => new NullLogger(),
'errorLogger' => static function ( Exception $e ) {
wfWarn( get_class( $e ) . ": {$e->getMessage()}" );
wfWarn( get_class( $e ) . ': ' . $e->getMessage() );
},
'deprecationLogger' => static function ( $msg ) {
wfWarn( $msg );

View file

@ -39,7 +39,7 @@ class RefreshLinksPartitionTest extends MediaWikiIntegrationTestCase {
);
$job = new RefreshLinksJob( $title, [ 'recursive' => true, 'table' => 'pagelinks' ]
+ Job::newRootJobParams( "refreshlinks:pagelinks:{$title->getPrefixedText()}" ) );
+ Job::newRootJobParams( 'refreshlinks:pagelinks:' . $title->getPrefixedText() ) );
$extraParams = $job->getRootJobParams();
$jobs = BacklinkJobUtils::partitionBacklinkJob( $job, 9, 1, [ 'params' => $extraParams ] );

View file

@ -115,7 +115,7 @@ class SessionBackendTest extends MediaWikiIntegrationTestCase {
$this->fail( 'Expected exception not thrown' );
} catch ( \InvalidArgumentException $ex ) {
$this->assertSame(
"Refusing to create session for unverified user {$info->getUserInfo()}",
'Refusing to create session for unverified user ' . $info->getUserInfo(),
$ex->getMessage()
);
}

View file

@ -400,11 +400,15 @@ class RollbackPageTest extends MediaWikiIntegrationTestCase {
$currentTimestamp = $this->getServiceContainer()
->getContentLanguage()
->timeanddate( $revisions['revision-two']->getTimestamp() );
$expectedSummary = "TEST! {$admin->getName()} {$user1->getName()}" .
" {$revisions['revision-one']->getId()}" .
" {$targetTimestamp}" .
" {$revisions['revision-two']->getId()}" .
" {$currentTimestamp}";
$expectedSummary = implode( ' ', [
'TEST!',
$admin->getName(),
$user1->getName(),
$revisions['revision-one']->getId(),
$targetTimestamp,
$revisions['revision-two']->getId(),
$currentTimestamp
] );
$this->assertSame( $expectedSummary, $page->getRevisionRecord()->getComment()->text );
$rc = $this->getServiceContainer()->getRevisionStore()->getRecentChange( $page->getRevisionRecord() );
$this->assertNotNull( $rc );

View file

@ -39,7 +39,7 @@ abstract class HookRunnerTestBase extends MediaWikiUnitTestCase {
}
);
$this->assertCount( 1, $interfacesWithMethod,
"Exactly one hook interface must have method {$method->getName()}" );
'Exactly one hook interface must have method ' . $method->getName() );
}
}

View file

@ -322,7 +322,7 @@ function wfStreamThumb( array $params ) {
// Suggest a good name for users downloading this thumbnail
$headers[] =
"Content-Disposition: {$img->getThumbDisposition( $thumbName, $dispositionType )}";
'Content-Disposition: ' . $img->getThumbDisposition( $thumbName, $dispositionType );
if ( count( $varyHeader ) ) {
$headers[] = 'Vary: ' . implode( ', ', $varyHeader );