Skip to content

Commit

Permalink
minor #6171 Fix tests and CS (SpacePossum)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

Fix tests and CS

Commits
-------

e4c4b9f Fix tests and CS.
  • Loading branch information
SpacePossum committed Dec 14, 2021
2 parents 4ecba58 + e4c4b9f commit ea5a185
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -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'
Expand Down
6 changes: 4 additions & 2 deletions src/Tokenizer/Tokens.php
Expand Up @@ -859,8 +859,10 @@ public function insertSlices(array $slices): void

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;
Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/Transformer/ReturnRefTransformer.php
Expand Up @@ -46,7 +46,7 @@ public function process(Tokens $tokens, Token $token, int $index): void
$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, '&']);
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php
Expand Up @@ -518,7 +518,6 @@ public function testInvalidConfigurationValue(): void
}

/**
* @requires PHP 7.1
* @dataProvider provideFixClassConstCases
*/
public function testFixClassConst(string $expected, string $input): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Tokenizer/TokensTest.php
Expand Up @@ -1485,8 +1485,8 @@ public function provideInsertSlicesCases(): iterable

$slices = [
[0 => $openTagToken],
[0 => [$openTagToken]],
[0 => Tokens::fromArray([$openTagToken])],
[0 => [clone $openTagToken]],
[0 => clone Tokens::fromArray([$openTagToken])],
];

foreach ($slices as $i => $slice) {
Expand Down

0 comments on commit ea5a185

Please sign in to comment.