Browse Source

CS/SCA/tweaks/additonal tests/Grammar/Typos

SpacePossum 3 years ago
parent
commit
df52f67a92

+ 1 - 1
doc/ruleSets/DoctrineAnnotation.rst

@@ -2,7 +2,7 @@
 Rule set ``@DoctrineAnnotation``
 ================================
 
-Rules covering Doctrine annotations with configuration based on examples found in `Doctrine Annotation documentation <https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/annotations.html>`_ and `Symfony documentation <http://symfony.com/doc/master/bundles/SensioFrameworkExtraBundle/annotations/routing.html>`_.
+Rules covering Doctrine annotations with configuration based on examples found in `Doctrine Annotation documentation <https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/annotations.html>`_ and `Symfony documentation <https://symfony.com/doc/master/bundles/SensioFrameworkExtraBundle/annotations/routing.html>`_.
 
 Rules
 -----

+ 2 - 2
src/AbstractFunctionReferenceFixer.php

@@ -63,9 +63,9 @@ abstract class AbstractFunctionReferenceFixer extends AbstractFixer
         // find raw sequence which we can analyse for context
         $candidateSequence = [[T_STRING, $functionNameToSearch], '('];
         $matches = $tokens->findSequence($candidateSequence, $start, $end, false);
+
         if (null === $matches) {
-            // not found, simply return without further attempts
-            return null;
+            return null; // not found, simply return without further attempts
         }
 
         // translate results for humans

+ 1 - 1
src/AbstractNoUselessElseFixer.php

@@ -143,7 +143,7 @@ abstract class AbstractNoUselessElseFixer extends AbstractFixer
     /**
      * For internal use only, as it is not perfect.
      *
-     * Returns if the token at given index is part of a if/elseif/else statement
+     * Returns if the token at given index is part of an if/elseif/else statement
      * without {}. Assumes not passing the last `;`/close tag of the statement, not
      * out of range index, etc.
      *

+ 1 - 1
src/Cache/FileCacheManager.php

@@ -66,7 +66,7 @@ final class FileCacheManager implements CacheManagerInterface
         $this->handler = $handler;
         $this->signature = $signature;
         $this->isDryRun = $isDryRun;
-        $this->cacheDirectory = $cacheDirectory ?: new Directory('');
+        $this->cacheDirectory = $cacheDirectory ?? new Directory('');
 
         $this->readCache();
     }

+ 1 - 1
src/Console/Command/SelfUpdateCommand.php

@@ -126,7 +126,7 @@ EOT
         }
 
         if (1 !== $this->versionChecker->compareVersions($latestVersion, $currentVersion)) {
-            $output->writeln('<info>PHP CS Fixer is already up to date.</info>');
+            $output->writeln('<info>PHP CS Fixer is already up-to-date.</info>');
 
             return 0;
         }

+ 6 - 6
src/Console/Report/FixReport/JsonReporter.php

@@ -36,24 +36,24 @@ final class JsonReporter implements ReporterInterface
      */
     public function generate(ReportSummary $reportSummary): string
     {
-        $jFiles = [];
+        $jsonFiles = [];
 
         foreach ($reportSummary->getChanged() as $file => $fixResult) {
-            $jfile = ['name' => $file];
+            $jsonFile = ['name' => $file];
 
             if ($reportSummary->shouldAddAppliedFixers()) {
-                $jfile['appliedFixers'] = $fixResult['appliedFixers'];
+                $jsonFile['appliedFixers'] = $fixResult['appliedFixers'];
             }
 
             if (!empty($fixResult['diff'])) {
-                $jfile['diff'] = $fixResult['diff'];
+                $jsonFile['diff'] = $fixResult['diff'];
             }
 
-            $jFiles[] = $jfile;
+            $jsonFiles[] = $jsonFile;
         }
 
         $json = [
-            'files' => $jFiles,
+            'files' => $jsonFiles,
             'time' => [
                 'total' => round($reportSummary->getTime() / 1000, 3),
             ],

+ 9 - 0
src/Fixer/Alias/BacktickToShellExecFixer.php

@@ -75,6 +75,7 @@ EOT
         $backtickTokens = [];
         for ($index = $tokens->count() - 1; $index > 0; --$index) {
             $token = $tokens[$index];
+
             if (!$token->equals('`')) {
                 if ($backtickStarted) {
                     $backtickTokens[$index] = $token;
@@ -84,10 +85,12 @@ EOT
             }
 
             $backtickTokens[$index] = $token;
+
             if ($backtickStarted) {
                 $this->fixBackticks($tokens, $backtickTokens);
                 $backtickTokens = [];
             }
+
             $backtickStarted = !$backtickStarted;
         }
     }
@@ -117,15 +120,18 @@ EOT
             new Token([T_STRING, 'shell_exec']),
             new Token('('),
         ];
+
         if (1 !== $count) {
             $newTokens[] = new Token('"');
         }
+
         foreach ($backtickTokens as $token) {
             if (!$token->isGivenKind(T_ENCAPSED_AND_WHITESPACE)) {
                 $newTokens[] = $token;
 
                 continue;
             }
+
             $content = $token->getContent();
             // Escaping special chars depends on the context: too tricky
             if (Preg::match('/[`"\']/u', $content)) {
@@ -133,6 +139,7 @@ EOT
             }
 
             $kind = T_ENCAPSED_AND_WHITESPACE;
+
             if (1 === $count) {
                 $content = '"'.$content.'"';
                 $kind = T_CONSTANT_ENCAPSED_STRING;
@@ -140,9 +147,11 @@ EOT
 
             $newTokens[] = new Token([$kind, $content]);
         }
+
         if (1 !== $count) {
             $newTokens[] = new Token('"');
         }
+
         $newTokens[] = new Token(')');
 
         $tokens->overrideRange($openingBacktickIndex, $closingBacktickIndex, $newTokens);

+ 2 - 1
src/Fixer/Alias/EregToPregFixer.php

@@ -163,6 +163,7 @@ final class EregToPregFixer extends AbstractFixer
     {
         // try to find something that's not used
         $delimiters = [];
+
         foreach (self::$delimiters as $k => $d) {
             if (!str_contains($pattern, $d)) {
                 return $d;
@@ -171,7 +172,7 @@ final class EregToPregFixer extends AbstractFixer
             $delimiters[$d] = [substr_count($pattern, $d), $k];
         }
 
-        // return the least used delimiter, using the position in the list as a tie breaker
+        // return the least used delimiter, using the position in the list as a tiebreaker
         uasort($delimiters, static function (array $a, array $b): int {
             if ($a[0] === $b[0]) {
                 return $a[1] <=> $b[1];

+ 1 - 1
src/Fixer/Alias/PowToExponentiationFixer.php

@@ -151,7 +151,7 @@ final class PowToExponentiationFixer extends AbstractFunctionReferenceFixer
 
         $added = 0;
 
-        // check if the arguments need to be wrapped in parenthesis
+        // check if the arguments need to be wrapped in parentheses
         foreach (array_reverse($arguments, true) as $argumentStartIndex => $argumentEndIndex) {
             if ($this->isParenthesisNeeded($tokens, $argumentStartIndex, $argumentEndIndex)) {
                 $tokens->insertAt($argumentEndIndex + 1, new Token(')'));

+ 1 - 0
src/Fixer/ArrayNotation/ArraySyntaxFixer.php

@@ -97,6 +97,7 @@ final class ArraySyntaxFixer extends AbstractFixer implements ConfigurableFixerI
     protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
     {
         $callback = $this->fixCallback;
+
         for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
             if ($tokens[$index]->isGivenKind($this->candidateTokenKind)) {
                 $this->{$callback}($tokens, $index);

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