Browse Source

DX: reapply newest CS

Dariusz Ruminski 7 years ago
parent
commit
f3aa5c0271

+ 1 - 0
src/AbstractLinesBeforeNamespaceFixer.php

@@ -51,6 +51,7 @@ abstract class AbstractLinesBeforeNamespaceFixer extends AbstractFixer implement
                     if ($newlineInOpening) {
                         ++$precedingNewlines;
                     }
+
                     break;
                 }
                 if (false === $token->isGivenKind(T_WHITESPACE)) {

+ 8 - 8
src/Console/Command/HelpCommand.php

@@ -44,7 +44,7 @@ final class HelpCommand extends BaseHelpCommand
     public static function getHelpCopy()
     {
         $template =
-            <<<EOF
+            <<<'EOF'
 The <info>%command.name%</info> command tries to fix as much coding standards
 problems as possible on a given file or files in a given directory and its subdirectories:
 
@@ -137,7 +137,7 @@ The example below will add two rules to the default list of PSR2 set rules:
 
     <?php
 
-    \$finder = PhpCsFixer\Finder::create()
+    $finder = PhpCsFixer\Finder::create()
         ->exclude('somedir')
         ->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
         ->in(__DIR__)
@@ -149,7 +149,7 @@ The example below will add two rules to the default list of PSR2 set rules:
             'strict_param' => true,
             'array_syntax' => array('syntax' => 'short'),
         ))
-        ->setFinder(\$finder)
+        ->setFinder($finder)
     ;
 
     ?>
@@ -164,7 +164,7 @@ The following example shows how to use all ``Symfony`` rules but the ``full_open
 
     <?php
 
-    \$finder = PhpCsFixer\Finder::create()
+    $finder = PhpCsFixer\Finder::create()
         ->exclude('somedir')
         ->in(__DIR__)
     ;
@@ -174,7 +174,7 @@ The following example shows how to use all ``Symfony`` rules but the ``full_open
             '@Symfony' => true,
             'full_opening_tag' => false,
         ))
-        ->setFinder(\$finder)
+        ->setFinder($finder)
     ;
 
     ?>
@@ -185,8 +185,8 @@ configure them in your config file.
     <?php
 
     return PhpCsFixer\Config::create()
-        ->setIndent("\\t")
-        ->setLineEnding("\\r\\n")
+        ->setIndent("\t")
+        ->setLineEnding("\r\n")
     ;
 
     ?>
@@ -234,7 +234,7 @@ Then, add the following command to your CI:
 
 %%%CI_INTEGRATION%%%
 
-Where ``\$COMMIT_RANGE`` is your range of commits, eg ``\$TRAVIS_COMMIT_RANGE`` or ``HEAD~..HEAD``.
+Where ``$COMMIT_RANGE`` is your range of commits, eg ``$TRAVIS_COMMIT_RANGE`` or ``HEAD~..HEAD``.
 
 Exit codes
 ----------

+ 4 - 4
src/Console/Command/ReadmeCommand.php

@@ -236,15 +236,15 @@ EOF;
         $help = preg_replace("#^\n( +\\$ )#m", "\n.. code-block:: bash\n\n$1", $help);
         $help = preg_replace("#^\n( +<\\?php)#m", "\n.. code-block:: php\n\n$1", $help);
         $help = preg_replace_callback(
-            "#^\s*<\?(\w+).*?\?>#ms",
+            '#^\\s*<\\?(\\w+).*?\\?>#ms',
             function ($matches) {
-                $result = preg_replace("#^\.\. code-block:: bash\n\n#m", '', $matches[0]);
+                $result = preg_replace("#^\\.\\. code-block:: bash\n\n#m", '', $matches[0]);
 
                 if ('php' !== $matches[1]) {
-                    $result = preg_replace("#<\?{$matches[1]}\s*#", '', $result);
+                    $result = preg_replace("#<\\?{$matches[1]}\\s*#", '', $result);
                 }
 
-                $result = preg_replace("#\n\n +\?>#", '', $result);
+                $result = preg_replace("#\n\n +\\?>#", '', $result);
 
                 return $result;
             },

+ 1 - 1
src/Console/Output/ErrorOutput.php

@@ -62,7 +62,7 @@ final class ErrorOutput
                     $message = $e->getMessage();
                     $code = $e->getCode();
                     if (0 !== $code) {
-                        $message .= " ($code)";
+                        $message .= " (${code})";
                     }
 
                     $length = max(strlen($class), strlen($message));

+ 1 - 1
src/DocBlock/Tag.php

@@ -92,7 +92,7 @@ class Tag
             throw new \RuntimeException('Cannot set name on unknown tag.');
         }
 
-        $this->line->setContent(preg_replace("/@$current/", "@$name", $this->line->getContent(), 1));
+        $this->line->setContent(preg_replace("/@${current}/", "@${name}", $this->line->getContent(), 1));
 
         $this->name = $name;
     }

+ 5 - 3
src/Fixer/LanguageConstruct/ClassKeywordRemoveFixer.php

@@ -129,9 +129,11 @@ $className = Baz::class;
             // Imports group (PHP 7 spec)
             if ($tokens[$index]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_OPEN)) {
                 $groupEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_GROUP_IMPORT_BRACE, $index);
-                $groupImports = array_map(function ($import) {
-                    return trim($import);
-                }, explode(',', $tokens->generatePartialCode($index + 1, $groupEndIndex - 1))
+                $groupImports = array_map(
+                    function ($import) {
+                        return trim($import);
+                    },
+                    explode(',', $tokens->generatePartialCode($index + 1, $groupEndIndex - 1))
                 );
                 foreach ($groupImports as $groupImport) {
                     $groupImportParts = array_map(function ($import) {

+ 1 - 1
src/PharCheckerInterface.php

@@ -20,7 +20,7 @@ interface PharCheckerInterface
     /**
      * @param string $filename
      *
-     * @return string|null the invalidity reason if any, null otherwise
+     * @return null|string the invalidity reason if any, null otherwise
      */
     public function checkFileValidity($filename);
 }

+ 1 - 1
src/Tokenizer/Tokens.php

@@ -1232,7 +1232,7 @@ class Tokens extends \SplFixedArray
      * @param string $key   item key
      * @param Tokens $value item value
      */
-    private static function setCache($key, Tokens $value)
+    private static function setCache($key, self $value)
     {
         self::$cache[$key] = $value;
     }

+ 2 - 2
tests/AutoReview/ProjectCodeTest.php

@@ -145,7 +145,7 @@ final class ProjectCodeTest extends TestCase
                 "Class '%s' should not have public methods that are not part of implemented interfaces.\nViolations:\n%s",
                 $className,
                 implode("\n", array_map(function ($item) {
-                    return " * $item";
+                    return " * ${item}";
                 }, $extraMethods))
             )
         );
@@ -210,7 +210,7 @@ final class ProjectCodeTest extends TestCase
                 "Class '%s' should not have protected properties.\nViolations:\n%s",
                 $className,
                 implode("\n", array_map(function ($item) {
-                    return " * $item";
+                    return " * ${item}";
                 }, $extraProps))
             )
         );

+ 10 - 4
tests/Cache/FileHandlerTest.php

@@ -155,8 +155,11 @@ final class FileHandlerTest extends TestCase
 
         $this->setExpectedExceptionRegExp(
             'Symfony\Component\Filesystem\Exception\IOException',
-            sprintf('#^%s$#', preg_quote('Cannot write cache file "'.realpath($dir).'" as the location exists as directory.', '#')
-        ));
+            sprintf(
+                '#^%s$#',
+                preg_quote('Cannot write cache file "'.realpath($dir).'" as the location exists as directory.', '#')
+            )
+        );
 
         $handler->write(new Cache(new Signature(
             PHP_VERSION,
@@ -181,8 +184,11 @@ final class FileHandlerTest extends TestCase
 
         $this->setExpectedExceptionRegExp(
             'Symfony\Component\Filesystem\Exception\IOException',
-            sprintf('#^%s$#', preg_quote('Cannot write to file "'.realpath($file).'" as it is not writable.', '#')
-        ));
+            sprintf(
+                '#^%s$#',
+                preg_quote('Cannot write to file "'.realpath($file).'" as it is not writable.', '#')
+            )
+        );
 
         $handler->write(new Cache(new Signature(
             PHP_VERSION,

Some files were not shown because too many files changed in this diff