Skip to content

Commit

Permalink
fix typo...
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacePossum committed Oct 11, 2023
1 parent 5bf8103 commit 4687e5a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/SelfAccessorFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function replaceNameOccurrences(Tokens $tokens, string $namespace, strin
}

if ($token->isGivenKind(T_FN)) {
$i = $tokensAnalyzer->getLastTokenIndexOArrowFunction($i);
$i = $tokensAnalyzer->getLastTokenIndexOfArrowFunction($i);
$i = $tokens->getNextMeaningfulToken($i);

continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/FunctionNotation/StaticLambdaFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$lambdaEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $lambdaOpenIndex);
} else { // T_FN
$lambdaOpenIndex = $tokens->getNextTokenOfKind($argumentsEndIndex, [[T_DOUBLE_ARROW]]);
$lambdaEndIndex = $analyzer->getLastTokenIndexOArrowFunction($index);
$lambdaEndIndex = $analyzer->getLastTokenIndexOfArrowFunction($index);
}

if ($this->hasPossibleReferenceToThis($tokens, $lambdaOpenIndex, $lambdaEndIndex)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Operator/BinaryOperatorSpacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ private function injectAlignmentPlaceholdersDefault(Tokens $tokens, int $startAt

if ($token->isGivenKind(T_FN)) {
$from = $tokens->getNextMeaningfulToken($index);
$until = $this->tokensAnalyzer->getLastTokenIndexOArrowFunction($index);
$until = $this->tokensAnalyzer->getLastTokenIndexOfArrowFunction($index);
$this->injectAlignmentPlaceholders($tokens, $from + 1, $until - 1, $tokenContent);
$index = $until;

Expand Down Expand Up @@ -715,7 +715,7 @@ private function injectAlignmentPlaceholdersForArrow(Tokens $tokens, int $startA
if ($token->isGivenKind(T_FN)) {
$yieldFoundSinceLastPlaceholder = false;
$from = $tokens->getNextMeaningfulToken($index);
$until = $this->tokensAnalyzer->getLastTokenIndexOArrowFunction($index);
$until = $this->tokensAnalyzer->getLastTokenIndexOfArrowFunction($index);
$this->injectArrayAlignmentPlaceholders($tokens, $from + 1, $until - 1);
$index = $until;

Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/TokensAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function isLambda(int $index): bool
return $startParenthesisToken->equals('(');
}

public function getLastTokenIndexOArrowFunction(int $index): int
public function getLastTokenIndexOfArrowFunction(int $index): int
{
if (!$this->tokens[$index]->isGivenKind(T_FN)) {
throw new \InvalidArgumentException(sprintf('Not an "arrow function" at given index %d.', $index));
Expand Down
12 changes: 6 additions & 6 deletions tests/Tokenizer/TokensAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2803,25 +2803,25 @@ public function testGetClassyModifiersForNonClassyThrowsAnException(): void
}

/**
* @dataProvider provideGetLastTokenIndexOArrowFunctionCases
* @dataProvider provideGetLastTokenIndexOfArrowFunctionCases
*
* @param array<int, int> $expectations
*/
public function testGetLastTokenIndexOArrowFunction(array $expectations, string $source): void
public function testGetLastTokenIndexOfArrowFunction(array $expectations, string $source): void
{
$tokens = Tokens::fromCode($source);
$tokensAnalyzer = new TokensAnalyzer($tokens);

$indices = [];

foreach ($expectations as $index => $expectedEndIndex) {
$indices[$index] = $tokensAnalyzer->getLastTokenIndexOArrowFunction($index);
$indices[$index] = $tokensAnalyzer->getLastTokenIndexOfArrowFunction($index);
}

self::assertSame($expectations, $indices);
}

public static function provideGetLastTokenIndexOArrowFunctionCases(): iterable
public static function provideGetLastTokenIndexOfArrowFunctionCases(): iterable
{
yield 'simple cases' => [
[
Expand Down Expand Up @@ -2918,14 +2918,14 @@ public static function provideGetLastTokenIndexOArrowFunctionCases(): iterable
];
}

public function testCannotGetLastTokenIndexOArrowFunctionForNonFnToken(): void
public function testCannotGetLastTokenIndexOfArrowFunctionForNonFnToken(): void
{
$tokens = Tokens::fromCode('<?php echo 1;');
$tokensAnalyzer = new TokensAnalyzer($tokens);

$this->expectException(\InvalidArgumentException::class);

$tokensAnalyzer->getLastTokenIndexOArrowFunction(1);
$tokensAnalyzer->getLastTokenIndexOfArrowFunction(1);
}

/**
Expand Down

0 comments on commit 4687e5a

Please sign in to comment.