Browse Source

Fix tests and CS.

SpacePossum 3 years ago
parent
commit
e4c4b9f3d3

+ 3 - 1
.github/workflows/ci.yml

@@ -124,7 +124,9 @@ jobs:
         env:
           PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
           FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
-        run: vendor/bin/phpunit ${{ matrix.phpunit-flags }}
+        run: |
+          php -v
+          vendor/bin/phpunit ${{ matrix.phpunit-flags }}
 
       - name: Upload coverage results to Coveralls
         if: matrix.calculate-code-coverage == 'yes'

+ 4 - 2
src/Tokenizer/Tokens.php

@@ -859,8 +859,10 @@ class Tokens extends \SplFixedArray
 
         krsort($slices);
 
-        if (array_key_first($slices) > $oldSize) {
-            throw new \OutOfBoundsException('Cannot insert outside of collection.');
+        $firstIndex = key($slices);
+
+        if (!\is_int($firstIndex) || $firstIndex > $oldSize) {
+            throw new \OutOfBoundsException(sprintf('Invalid index "%s".', $firstIndex));
         }
 
         $insertBound = $oldSize - 1;

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

@@ -46,7 +46,7 @@ final class ReturnRefTransformer extends AbstractTransformer
             $prevKinds[] = T_FN;
         }
 
-        if (($token->equals('&')) && $tokens[$tokens->getPrevMeaningfulToken($index)]->isGivenKind($prevKinds)) {
+        if ($token->equals('&') && $tokens[$tokens->getPrevMeaningfulToken($index)]->isGivenKind($prevKinds)) {
             $tokens[$index] = new Token([CT::T_RETURN_REF, '&']);
         }
     }

+ 0 - 1
tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php

@@ -518,7 +518,6 @@ EOF;
     }
 
     /**
-     * @requires PHP 7.1
      * @dataProvider provideFixClassConstCases
      */
     public function testFixClassConst(string $expected, string $input): void

+ 2 - 2
tests/Tokenizer/TokensTest.php

@@ -1485,8 +1485,8 @@ EOF
 
         $slices = [
             [0 => $openTagToken],
-            [0 => [$openTagToken]],
-            [0 => Tokens::fromArray([$openTagToken])],
+            [0 => [clone $openTagToken]],
+            [0 => clone Tokens::fromArray([$openTagToken])],
         ];
 
         foreach ($slices as $i => $slice) {