Browse Source

Merge branch 'master' into 3.0

# Conflicts:
#	phpstan.neon
Dariusz Ruminski 3 years ago
parent
commit
e8c2ecd291

+ 4 - 4
dev-tools/composer.json

@@ -3,14 +3,14 @@
         "php": "^7.1"
     },
     "require-dev": {
-        "ergebnis/composer-normalize": "^2.11",
+        "ergebnis/composer-normalize": "^2.13",
         "humbug/box": "^3.8",
         "jangregor/phpstan-prophecy": "^0.6",
         "maglnet/composer-require-checker": "2.0.0",
         "mi-schi/phpmd-extension": "^4.3",
-        "phpmd/phpmd": "^2.9",
-        "phpstan/phpstan": "0.12.19",
-        "phpstan/phpstan-phpunit": "^0.12.8"
+        "phpmd/phpmd": "^2.10",
+        "phpstan/phpstan": "0.12.25",
+        "phpstan/phpstan-phpunit": "0.12.11"
     },
     "config": {
         "optimize-autoloader": true,

+ 2 - 2
doc/usage.rst

@@ -14,8 +14,8 @@ problems as possible on a given file or files in a given directory and its subdi
     $ php php-cs-fixer.phar fix /path/to/file
 
 By default ``--path-mode`` is set to ``override``, which means, that if you specify the path to a file or a directory via
-command arguments, then the paths provided to a ``Finder`` in config file will be ignored. You can use ``--path-mode=intersection``
-to merge paths from the config file and from the argument:
+command arguments, then the paths provided to a ``Finder`` in config file will be ignored. You can also use ``--path-mode=intersection``,
+which will use the intersection of the paths from the config file and from the argument:
 
 .. code-block:: console
 

+ 0 - 14
phpstan.neon

@@ -12,21 +12,7 @@ parameters:
         - tests/Fixtures
     ignoreErrors:
         - '/^Constant T_NAME_(RELATIVE|FULLY_QUALIFIED|QUALIFIED) not found\.$/'
-        -
-            message: '/^Strict comparison using !== between ''@git-commit@'' and ''@git-commit@'' will always evaluate to false\.$/'
-            path: src/Console/Application.php
-        -
-            message: '/^Else branch is unreachable because ternary operator condition is always true\.$/'
-            paths:
-                - src/Tokenizer/Token.php
-        - # https://github.com/phpstan/phpstan/issues/1215
-            message: '/^Strict comparison using === between false and string will always evaluate to false\.$/'
-            path: src/Fixer/StringNotation/NoTrailingWhitespaceInStringFixer.php
         -
             message: '/^Constant T_ATTRIBUTE not found\.$/'
             path: src/Tokenizer/Transformer/AttributeTransformer.php
-        -
-            message: '/^\$this\(PhpCsFixer\\Tokenizer\\Tokens\) does not accept PhpCsFixer\\Tokenizer\\Token\|null\.$/'
-            path: src/Tokenizer/Tokens.php
-
     tipsOfTheDay: false

+ 1 - 1
src/Console/Application.php

@@ -103,7 +103,7 @@ final class Application extends BaseApplication
 
         $commit = '@git-commit@';
 
-        if ('@'.'git-commit@' !== $commit) {
+        if ('@'.'git-commit@' !== $commit) { // @phpstan-ignore-line as `$commit` is replaced during phar building
             $version .= ' ('.substr($commit, 0, 7).')';
         }
 

+ 1 - 1
src/Fixer/StringNotation/NoTrailingWhitespaceInStringFixer.php

@@ -92,7 +92,7 @@ final class NoTrailingWhitespaceInStringFixer extends AbstractFixer
             if ($tokens[$prev]->equals([T_CLOSE_TAG, '?>']) && Preg::match('/^\R/', $content, $match)) {
                 $tokens[$prev] = new Token([T_CLOSE_TAG, $tokens[$prev]->getContent().$match[0]]);
                 $content = substr($content, \strlen($match[0]));
-                $content = false === $content ? '' : $content;
+                $content = false === $content ? '' : $content; // @phpstan-ignore-line due to https://github.com/phpstan/phpstan/issues/1215 , awaiting PHP8 as min requirement of Fixer
             }
 
             $this->updateContent($tokens, $index, $content);

+ 1 - 0
src/Tokenizer/Token.php

@@ -87,6 +87,7 @@ final class Token
         } else {
             throw new \InvalidArgumentException(sprintf(
                 'Cannot recognize input value as valid Token prototype, got "%s".',
+                // @phpstan-ignore-next-line due to lack of strong typing of method parameter
                 \is_object($token) ? \get_class($token) : \gettype($token)
             ));
         }

+ 1 - 1
src/Tokenizer/Tokens.php

@@ -340,7 +340,7 @@ class Tokens extends \SplFixedArray
 
         for ($count = $index; $index < $limit; ++$index) {
             if (!$this->isEmptyAt($index)) {
-                $this[$count++] = $this[$index];
+                $this[$count++] = $this[$index]; // @phpstan-ignore-line as we know that index exists
             }
         }
 

+ 13 - 1
tests/RuleSet/RuleSetsTest.php

@@ -292,6 +292,18 @@ Integration of %s.
         $factory->registerBuiltInFixers();
         $factory->useRuleSet(new RuleSet([$name => true]));
 
-        return current($factory->getFixers());
+        $fixers = $factory->getFixers();
+
+        if (empty($fixers)) {
+            throw new \RuntimeException('FixerFactory unexpectedly returned empty array.');
+        }
+
+        $fixer = current($fixers);
+
+        if (!$fixer instanceof AbstractFixer) {
+            throw new \RuntimeException(sprintf('Fixer class for "%s" rule does not extend "%s".', $name, AbstractFixer::class));
+        }
+
+        return $fixer;
     }
 }