Dariusz Ruminski 5 лет назад
Родитель
Сommit
8ba82ef73a

+ 1 - 1
.travis.yml

@@ -52,7 +52,7 @@ jobs:
                     | grep -v tests/TestCase.php \
                     | grep -v tests/TestCase.php \
                     && (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
                     && (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
                 - ./check_trailing_spaces.sh || travis_terminate 1
                 - ./check_trailing_spaces.sh || travis_terminate 1
-                - ./dev-tools/tools/phpstan analyse
+                - php -d auto_prepend_file=dev-tools/vendor/autoload.php ./dev-tools/tools/phpstan analyse
                 - if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^tests/Fixtures" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
                 - if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^tests/Fixtures" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
                 - ./dev-tools/tools/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json) || travis_terminate 1
                 - ./dev-tools/tools/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json) || travis_terminate 1
                 - composer normalize -d ./dev-tools ./../composer.json --dry-run
                 - composer normalize -d ./dev-tools ./../composer.json --dry-run

+ 2 - 1
dev-tools/composer.json

@@ -6,7 +6,8 @@
         "humbug/box": "~3.7.0",
         "humbug/box": "~3.7.0",
         "localheinz/composer-normalize": "^1.1",
         "localheinz/composer-normalize": "^1.1",
         "mi-schi/phpmd-extension": "^4.3",
         "mi-schi/phpmd-extension": "^4.3",
-        "phpmd/phpmd": "^2.6"
+        "phpmd/phpmd": "^2.6",
+        "phpstan/phpstan-phpunit": "^0.11.2"
     },
     },
     "conflict": {
     "conflict": {
         "hhvm": "*"
         "hhvm": "*"

+ 4 - 1
phpstan.neon

@@ -1,5 +1,8 @@
+includes:
+    - dev-tools/vendor/phpstan/phpstan-phpunit/extension.neon
+
 parameters:
 parameters:
-    level: 0
+    level: 1
     paths:
     paths:
         - src
         - src
         - tests
         - tests

+ 1 - 0
src/AbstractLinesBeforeNamespaceFixer.php

@@ -37,6 +37,7 @@ abstract class AbstractLinesBeforeNamespaceFixer extends AbstractFixer implement
     {
     {
         // Let's determine the total numbers of new lines before the namespace
         // Let's determine the total numbers of new lines before the namespace
         // and the opening token
         // and the opening token
+        $openingTokenIndex = null;
         $precedingNewlines = 0;
         $precedingNewlines = 0;
         $newlineInOpening = false;
         $newlineInOpening = false;
         $openingToken = null;
         $openingToken = null;

+ 2 - 1
src/Console/Command/DescribeCommand.php

@@ -279,8 +279,9 @@ final class DescribeCommand extends Command
                 $old = $codeSample->getCode();
                 $old = $codeSample->getCode();
                 $tokens = Tokens::fromCode($old);
                 $tokens = Tokens::fromCode($old);
 
 
+                $configuration = $codeSample->getConfiguration();
+
                 if ($fixer instanceof ConfigurableFixerInterface) {
                 if ($fixer instanceof ConfigurableFixerInterface) {
-                    $configuration = $codeSample->getConfiguration();
                     $fixer->configure(null === $configuration ? [] : $configuration);
                     $fixer->configure(null === $configuration ? [] : $configuration);
                 }
                 }
 
 

+ 5 - 5
src/Fixer/Basic/BracesFixer.php

@@ -566,11 +566,11 @@ class Foo
                     continue;
                     continue;
                 }
                 }
 
 
-                if (!$isAnonymousClass) {
-                    $prevToken = $tokens[$closingParenthesisIndex - 1];
-                }
-
-                if (!$isAnonymousClass && $prevToken->isWhitespace() && false !== strpos($prevToken->getContent(), "\n")) {
+                if (
+                    !$isAnonymousClass
+                    && $tokens[$closingParenthesisIndex - 1]->isWhitespace()
+                    && false !== strpos($tokens[$closingParenthesisIndex - 1]->getContent(), "\n")
+                ) {
                     if (!$tokens[$startBraceIndex - 2]->isComment()) {
                     if (!$tokens[$startBraceIndex - 2]->isComment()) {
                         $tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, ' ');
                         $tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, ' ');
                     }
                     }

+ 2 - 0
src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php

@@ -230,6 +230,8 @@ class Sample
     {
     {
         static $methodAttr = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_ABSTRACT, T_FINAL, T_STATIC];
         static $methodAttr = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_ABSTRACT, T_FINAL, T_STATIC];
 
 
+        $nonWhiteAbove = null;
+
         // find out where the element definition starts
         // find out where the element definition starts
         $firstElementAttributeIndex = $elementIndex;
         $firstElementAttributeIndex = $elementIndex;
         for ($i = $elementIndex; $i > $classStartIndex; --$i) {
         for ($i = $elementIndex; $i > $classStartIndex; --$i) {

+ 1 - 0
src/Fixer/Import/SingleImportPerStatementFixer.php

@@ -99,6 +99,7 @@ final class SingleImportPerStatementFixer extends AbstractFixer implements White
     {
     {
         $groupPrefix = '';
         $groupPrefix = '';
         $comment = '';
         $comment = '';
+        $groupOpenIndex = null;
         for ($i = $index + 1;; ++$i) {
         for ($i = $index + 1;; ++$i) {
             if ($tokens[$i]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_OPEN)) {
             if ($tokens[$i]->isGivenKind(CT::T_GROUP_IMPORT_BRACE_OPEN)) {
                 $groupOpenIndex = $i;
                 $groupOpenIndex = $i;