Browse Source

Clean ups

SpacePossum 8 years ago
parent
commit
41745cc903

+ 1 - 5
src/Cache/FileCacheManager.php

@@ -84,11 +84,7 @@ final class FileCacheManager implements CacheManagerInterface
     {
         $file = $this->cacheDirectory->getRelativePathTo($file);
 
-        if (!$this->cache->has($file) || $this->cache->get($file) !== $this->calcHash($fileContent)) {
-            return true;
-        }
-
-        return false;
+        return !$this->cache->has($file) || $this->cache->get($file) !== $this->calcHash($fileContent);
     }
 
     public function setFile($file, $fileContent)

+ 6 - 1
src/Console/ConfigurationResolver.php

@@ -375,6 +375,9 @@ final class ConfigurationResolver
         return $this->cacheFile;
     }
 
+    /**
+     * @return bool
+     */
     public function getRiskyAllowed()
     {
         if (null === $this->allowRisky) {
@@ -554,7 +557,6 @@ final class ConfigurationResolver
         }
 
         $nestedFinder = null;
-        $iterator = null;
         $currentFinder = $this->iterableToTraversable($this->getConfig()->getFinder());
 
         try {
@@ -597,6 +599,9 @@ final class ConfigurationResolver
         return Finder::create()->in($pathsByType['dir'])->append($pathsByType['file']);
     }
 
+    /**
+     * @return bool
+     */
     private function isStdIn()
     {
         if (null === $this->isStdIn) {

+ 4 - 6
src/Fixer/FunctionNotation/FunctionDeclarationFixer.php

@@ -89,12 +89,10 @@ final class FunctionDeclarationFixer extends AbstractFixer
             // remove single-line edge whitespaces inside parameters list parentheses
             $this->fixParenthesisInnerEdge($tokens, $startParenthesisIndex, $endParenthesisIndex);
 
-            if (!$tokensAnalyzer->isLambda($index)) {
-                // remove whitespace before (
-                // eg: `function foo () {}` => `function foo() {}`
-                if ($tokens[$startParenthesisIndex - 1]->isWhitespace()) {
-                    $tokens[$startParenthesisIndex - 1]->clear();
-                }
+            // remove whitespace before (
+            // eg: `function foo () {}` => `function foo() {}`
+            if (!$tokensAnalyzer->isLambda($index) && $tokens[$startParenthesisIndex - 1]->isWhitespace()) {
+                $tokens[$startParenthesisIndex - 1]->clear();
             }
 
             // fix whitespace after T_FUNCTION

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

@@ -88,6 +88,8 @@ final class ClassKeywordRemoveFixer extends AbstractFixer
 
     /**
      * @param Tokens $tokens
+     * @param int    $startIndex
+     * @param int    $endIndex
      */
     private function storeImports(Tokens $tokens, $startIndex, $endIndex)
     {
@@ -100,7 +102,7 @@ final class ClassKeywordRemoveFixer extends AbstractFixer
             }
 
             $import = '';
-            while (($index = $tokens->getNextMeaningfulToken($index))) {
+            while ($index = $tokens->getNextMeaningfulToken($index)) {
                 if ($tokens[$index]->equalsAny(array(';', array(CT::T_GROUP_IMPORT_BRACE_OPEN))) || $tokens[$index]->isGivenKind(T_AS)) {
                     break;
                 }
@@ -135,6 +137,8 @@ final class ClassKeywordRemoveFixer extends AbstractFixer
 
     /**
      * @param Tokens $tokens
+     * @param int    $startIndex
+     * @param int    $endIndex
      */
     private function replaceClassKeywordsSection(Tokens $tokens, $startIndex, $endIndex)
     {

+ 0 - 2
src/Tokenizer/Tokens.php

@@ -322,8 +322,6 @@ class Tokens extends \SplFixedArray
         $removeLastCommentLine = function (Token $token, $indexOffset) {
             // because comments tokens are greedy and may consume single \n if we are putting whitespace after it let trim that \n
             if (1 === $indexOffset && $token->isComment()) {
-                $content = $token->getContent();
-
                 $token->setContent(preg_replace(
                     "#\r\n$|\n$#",
                     '',

+ 1 - 1
src/Tokenizer/Transformer/SquareBraceTransformer.php

@@ -30,7 +30,7 @@ use PhpCsFixer\Tokenizer\Tokens;
  */
 final class SquareBraceTransformer extends AbstractTransformer
 {
-    private $cacheOfArraySquareBraceCloseIndex = null;
+    private $cacheOfArraySquareBraceCloseIndex;
 
     /**
      * {@inheritdoc}

+ 2 - 16
tests/Console/ConfigurationResolverTest.php

@@ -27,12 +27,7 @@ final class ConfigurationResolverTest extends \PHPUnit_Framework_TestCase
     /**
      * @var Config
      */
-    protected $config;
-
-    /**
-     * @var ConfigurationResolver
-     */
-    protected $resolver;
+    private $config;
 
     protected function setUp()
     {
@@ -50,7 +45,7 @@ final class ConfigurationResolverTest extends \PHPUnit_Framework_TestCase
      */
     public function testSetOptionWithUndefinedOption()
     {
-        $resolver = new ConfigurationResolver(
+        new ConfigurationResolver(
             $this->config,
             array('foo' => 'bar'),
             ''
@@ -849,15 +844,6 @@ final class ConfigurationResolverTest extends \PHPUnit_Framework_TestCase
         );
     }
 
-    protected function makeFixersTest($expectedFixers, $resolvedFixers)
-    {
-        $this->assertCount(count($expectedFixers), $resolvedFixers);
-
-        foreach ($expectedFixers as $fixer) {
-            $this->assertContains($fixer, $resolvedFixers);
-        }
-    }
-
     private function assertSameRules(array $expected, array $actual, $message = '')
     {
         ksort($expected);

+ 2 - 4
tests/Tokenizer/CTTest.php

@@ -12,8 +12,6 @@
 
 namespace PhpCsFixer\Tests\Tokenizer;
 
-use PhpCsFixer\Tokenizer\CT;
-
 /**
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  *
@@ -33,7 +31,7 @@ final class CTTest extends \PHPUnit_Framework_TestCase
     public function testConstants($name, $value)
     {
         $this->assertGreaterThan(10000, $value);
-        $this->assertNull(@constant($name), 'The CT name must not use native T_* name');
+        $this->assertNull(@constant($name), 'The CT name must not use native T_* name.');
     }
 
     public function provideCTs()
@@ -52,7 +50,7 @@ final class CTTest extends \PHPUnit_Framework_TestCase
         static $constants;
 
         if (null === $constants) {
-            $reflection = new \ReflectionClass("PhpCsFixer\Tokenizer\CT");
+            $reflection = new \ReflectionClass('PhpCsFixer\Tokenizer\CT');
             $constants = $reflection->getConstants();
         }