Simplify strings in PHP code
authorFomafix <fomafix@googlemail.com>
Fri, 1 Mar 2019 21:15:22 +0000 (22:15 +0100)
committerFomafix <fomafix@googlemail.com>
Fri, 1 Mar 2019 21:16:26 +0000 (22:16 +0100)
Change-Id: I481810ade68b0c5a5be21d22e2a107646d5813e6

includes/Html.php
includes/actions/RawAction.php
includes/installer/Installer.php
includes/parser/Parser.php
includes/skins/Skin.php
maintenance/mergeMessageFileList.php
tests/phpunit/includes/jobqueue/JobTest.php
tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
tests/phpunit/includes/libs/stats/PrefixingStatsdDataFactoryProxyTest.php
tests/phpunit/includes/linker/LinkRendererTest.php

index 1e597b6..61785d5 100644 (file)
@@ -213,7 +213,7 @@ class Html {
                        // Silly XML.
                        return substr( $start, 0, -1 ) . '/>';
                } else {
-                       return "$start$contents" . self::closeElement( $element );
+                       return $start . $contents . self::closeElement( $element );
                }
        }
 
@@ -973,7 +973,7 @@ class Html {
                if ( $isXHTML ) { // XHTML5
                        // XML MIME-typed markup should have an xml header.
                        // However a DOCTYPE is not needed.
-                       $ret .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n";
+                       $ret .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
 
                        // Add the standard xmlns
                        $attribs['xmlns'] = 'http://www.w3.org/1999/xhtml';
index 73594bc..c8f1a8d 100644 (file)
@@ -116,7 +116,7 @@ class RawAction extends FormlessAction {
                                $elevatedText = $elevated ? 'by elevated ' : '';
                                $log = LoggerFactory::getInstance( "security" );
                                $log->warning(
-                                       "Unsafe JS/CSS/Json $elevatedText" . "load - {user} loaded {title} with {ctype}",
+                                       "Unsafe JS/CSS/Json {$elevatedText}load - {user} loaded {title} with {ctype}",
                                        [
                                                'user' => $this->getUser()->getName(),
                                                'title' => $title->getPrefixedDBKey(),
index 20661f2..3ac152e 100644 (file)
@@ -1184,8 +1184,8 @@ abstract class Installer {
        public function dirIsExecutable( $dir, $url ) {
                $scriptTypes = [
                        'php' => [
-                               "<?php echo 'ex' . 'ec';",
-                               "#!/var/env php\n<?php echo 'ex' . 'ec';",
+                               "<?php echo 'exec';",
+                               "#!/var/env php\n<?php echo 'exec';",
                        ],
                ];
 
index 0fe456d..deeb858 100644 (file)
@@ -1029,7 +1029,7 @@ class Parser {
                $matches = [];
 
                $taglist = implode( '|', $elements );
-               $start = "/<($taglist)(\\s+[^>]*?|\\s*?)(\/?" . ">)|<(!--)/i";
+               $start = "/<($taglist)(\\s+[^>]*?|\\s*?)(\/?>)|<(!--)/i";
 
                while ( $text != '' ) {
                        $p = preg_split( $start, $text, 2, PREG_SPLIT_DELIM_CAPTURE );
index 54dfff3..7ac2927 100644 (file)
@@ -530,14 +530,14 @@ abstract class Skin extends ContextSource {
                $colon = $this->msg( 'colon-separator' )->escaped();
 
                if ( !empty( $allCats['normal'] ) ) {
-                       $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
+                       $t = $embed . implode( $pop . $embed, $allCats['normal'] ) . $pop;
 
                        $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
                        $linkPage = $this->msg( 'pagecategorieslink' )->inContentLanguage()->text();
                        $title = Title::newFromText( $linkPage );
                        $link = $title ? Linker::link( $title, $msg ) : $msg;
                        $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
-                               $link . $colon . '<ul>' . $t . '</ul>' . '</div>';
+                               $link . $colon . '<ul>' . $t . '</ul></div>';
                }
 
                # Hidden categories
@@ -552,7 +552,7 @@ abstract class Skin extends ContextSource {
 
                        $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
                                $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
-                               $colon . '<ul>' . $embed . implode( "{$pop}{$embed}", $allCats['hidden'] ) . $pop . '</ul>' .
+                               $colon . '<ul>' . $embed . implode( $pop . $embed, $allCats['hidden'] ) . $pop . '</ul>' .
                                '</div>';
                }
 
index 51c41db..6ae506f 100644 (file)
@@ -185,7 +185,7 @@ if ( $queue ) {
 
 fwrite( STDERR, "\n" );
 $s =
-       "<" . "?php\n" .
+       "<?php\n" .
        "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" .
        "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" .
        '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" .
index 0cab702..769b193 100644 (file)
@@ -78,7 +78,7 @@ class JobTest extends MediaWikiTestCase {
                                '{"file":"db1023-bin.001288","pos":"308257743","asOfTime":' .
                                // Embed dynamically because TestSetup sets serialize_precision=17
                                // which, in PHP 7.1 and 7.2, produces 1457521464.3814001 instead
-                               json_encode( 1457521464.3814 ) . '} ' . 'triggeredRecursive=1 ' .
+                               json_encode( 1457521464.3814 ) . '} triggeredRecursive=1 ' .
                                $requestId
                        ],
                ];
index d739839..40c260c 100644 (file)
@@ -1853,7 +1853,7 @@ class DatabaseSQLTest extends PHPUnit\Framework\TestCase {
                } catch ( DBUnexpectedError $ex ) {
                        $this->assertSame(
                                'Invalid atomic section ended (got ' . __METHOD__ . ' but expected ' .
-                                       __METHOD__ . 'X' . ').',
+                                       __METHOD__ . 'X).',
                                $ex->getMessage()
                        );
                }
index b55d869..46e23e3 100644 (file)
@@ -31,7 +31,7 @@ class PrefixingStatsdDataFactoryProxyTest extends PHPUnit\Framework\TestCase {
                );
                $innerFactory->expects( $this->once() )
                        ->method( $method )
-                       ->with( 'testprefix.' . 'metricname' );
+                       ->with( 'testprefix.metricname' );
 
                $proxy = new PrefixingStatsdDataFactoryProxy( $innerFactory, 'testprefix' );
                // 1,2,3,4 simply makes sure we provide enough parameters, without caring what they are
@@ -48,7 +48,7 @@ class PrefixingStatsdDataFactoryProxyTest extends PHPUnit\Framework\TestCase {
                );
                $innerFactory->expects( $this->once() )
                        ->method( $method )
-                       ->with( 'testprefix.' . 'metricname' );
+                       ->with( 'testprefix.metricname' );
 
                $proxy = new PrefixingStatsdDataFactoryProxy( $innerFactory, 'testprefix...' );
                // 1,2,3,4 simply makes sure we provide enough parameters, without caring what they are
index 9b1a3dd..91ee276 100644 (file)
@@ -51,7 +51,7 @@ class LinkRendererTest extends MediaWikiLangTestCase {
 
                // Query added
                $this->assertEquals(
-                       '<a href="/w/index.php?title=Foobar&amp;foo=bar" ' . 'title="Foobar">Foobar</a>',
+                       '<a href="/w/index.php?title=Foobar&amp;foo=bar" title="Foobar">Foobar</a>',
                        $linkRenderer->makeKnownLink( $target, null, [], [ 'foo' => 'bar' ] )
                );