diff --git a/src/AbstractDoctrineAnnotationFixer.php b/src/AbstractDoctrineAnnotationFixer.php index 857067e1c2f..56d7f8fefd0 100644 --- a/src/AbstractDoctrineAnnotationFixer.php +++ b/src/AbstractDoctrineAnnotationFixer.php @@ -47,7 +47,7 @@ public function isCandidate(Tokens $tokens): bool */ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { - // fetch indexes one time, this is safe as we never add or remove a token during fixing + // fetch indices one time, this is safe as we never add or remove a token during fixing $analyzer = new TokensAnalyzer($tokens); $this->classyElements = $analyzer->getClassyElements(); diff --git a/src/DocBlock/Line.php b/src/DocBlock/Line.php index 5e757f5d777..3c6a349341b 100644 --- a/src/DocBlock/Line.php +++ b/src/DocBlock/Line.php @@ -102,7 +102,7 @@ public function setContent(string $content): void * Remove this line by clearing its contents. * * Note that this method technically brakes the internal state of the - * docblock, but is useful when we need to retain the indexes of lines + * docblock, but is useful when we need to retain the indices of lines * during the execution of an algorithm. */ public function remove(): void @@ -114,7 +114,7 @@ public function remove(): void * Append a blank docblock line to this line's contents. * * Note that this method technically brakes the internal state of the - * docblock, but is useful when we need to retain the indexes of lines + * docblock, but is useful when we need to retain the indices of lines * during the execution of an algorithm. */ public function addBlank(): void diff --git a/src/Fixer/Alias/BacktickToShellExecFixer.php b/src/Fixer/Alias/BacktickToShellExecFixer.php index a4fff83ca27..c778c084d62 100644 --- a/src/Fixer/Alias/BacktickToShellExecFixer.php +++ b/src/Fixer/Alias/BacktickToShellExecFixer.php @@ -102,7 +102,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void */ private function fixBackticks(Tokens $tokens, array $backtickTokens): void { - // Track indexes for final override + // Track indices for final override ksort($backtickTokens); $openingBacktickIndex = key($backtickTokens); end($backtickTokens); diff --git a/src/Fixer/Alias/EregToPregFixer.php b/src/Fixer/Alias/EregToPregFixer.php index 998c16d668b..21d44f8dedd 100644 --- a/src/Fixer/Alias/EregToPregFixer.php +++ b/src/Fixer/Alias/EregToPregFixer.php @@ -97,7 +97,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void break; } - // findSequence also returns the tokens, but we're only interested in the indexes, i.e.: + // findSequence also returns the tokens, but we're only interested in the indices, i.e.: // 0 => function name, // 1 => bracket "(" // 2 => quoted string passed as 1st parameter diff --git a/src/Fixer/Alias/ModernizeStrposFixer.php b/src/Fixer/Alias/ModernizeStrposFixer.php index 4022a380d90..d0f2cd4c3e8 100644 --- a/src/Fixer/Alias/ModernizeStrposFixer.php +++ b/src/Fixer/Alias/ModernizeStrposFixer.php @@ -127,19 +127,19 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } } - private function fixCall(Tokens $tokens, int $functionIndex, array $operatorIndexes): void + private function fixCall(Tokens $tokens, int $functionIndex, array $operatorIndices): void { foreach (self::REPLACEMENTS as $replacement) { - if (!$tokens[$operatorIndexes['operator_index']]->equals($replacement['operator'])) { + if (!$tokens[$operatorIndices['operator_index']]->equals($replacement['operator'])) { continue; } - if (!$tokens[$operatorIndexes['operand_index']]->equals($replacement['operand'], false)) { + if (!$tokens[$operatorIndices['operand_index']]->equals($replacement['operand'], false)) { continue; } - $tokens->clearTokenAndMergeSurroundingWhitespace($operatorIndexes['operator_index']); - $tokens->clearTokenAndMergeSurroundingWhitespace($operatorIndexes['operand_index']); + $tokens->clearTokenAndMergeSurroundingWhitespace($operatorIndices['operator_index']); + $tokens->clearTokenAndMergeSurroundingWhitespace($operatorIndices['operand_index']); $tokens->clearTokenAndMergeSurroundingWhitespace($functionIndex); if ($replacement['negate']) { diff --git a/src/Fixer/Alias/PowToExponentiationFixer.php b/src/Fixer/Alias/PowToExponentiationFixer.php index 2f749c5b2b4..30386770a89 100644 --- a/src/Fixer/Alias/PowToExponentiationFixer.php +++ b/src/Fixer/Alias/PowToExponentiationFixer.php @@ -73,7 +73,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void foreach (array_reverse($candidates) as $candidate) { // if in the previous iteration(s) tokens were added to the collection and this is done within the tokens - // indexes of the current candidate than the index of the close ')' of the candidate has moved and so + // indices of the current candidate than the index of the close ')' of the candidate has moved and so // the index needs to be updated if ($previousCloseParenthesisIndex < $candidate[2]) { $previousCloseParenthesisIndex = $candidate[2]; diff --git a/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php b/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php index fc853ff1845..33a22e78fd2 100644 --- a/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php +++ b/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php @@ -221,7 +221,7 @@ private function fixParent(Tokens $tokens, int $classStart, int $classEnd): void ], $classStart, $classEnd, [2 => false]); if (null !== $parentSeq) { - // we only need indexes + // we only need indices $parentSeq = array_keys($parentSeq); // match either of the possibilities @@ -242,7 +242,7 @@ private function fixParent(Tokens $tokens, int $classStart, int $classEnd): void ], $classStart, $classEnd, [2 => false]); if (null !== $parentSeq) { - // we only need indexes + // we only need indices $parentSeq = array_keys($parentSeq); // replace call with parent::__construct() @@ -378,7 +378,7 @@ private function findFunction(Tokens $tokens, string $name, int $startIndex, int return null; } - // keep only the indexes + // keep only the indices $function = array_keys($function); // find previous block, saving method modifiers for later use diff --git a/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php b/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php index 095cf449bbf..d3d839fb017 100644 --- a/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php +++ b/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php @@ -70,7 +70,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } /** - * @param int[] $candidates ',' indexes to fix + * @param int[] $candidates ',' indices to fix */ private function fixTraitUse(Tokens $tokens, int $useTraitIndex, array $candidates): void { @@ -99,7 +99,7 @@ private function fixTraitUse(Tokens $tokens, int $useTraitIndex, array $candidat */ private function getCandidates(Tokens $tokens, int $index): array { - $indexes = []; + $indices = []; $index = $tokens->getNextTokenOfKind($index, [',', ';', '{']); while (!$tokens[$index]->equals(';')) { @@ -107,10 +107,10 @@ private function getCandidates(Tokens $tokens, int $index): array return []; // do not fix use cases with grouping } - $indexes[] = $index; + $indices[] = $index; $index = $tokens->getNextTokenOfKind($index, [',', ';', '{']); } - return array_reverse($indexes); + return array_reverse($indices); } } diff --git a/src/Fixer/Comment/HeaderCommentFixer.php b/src/Fixer/Comment/HeaderCommentFixer.php index a5d3a6e0143..46c052ed6e3 100644 --- a/src/Fixer/Comment/HeaderCommentFixer.php +++ b/src/Fixer/Comment/HeaderCommentFixer.php @@ -141,19 +141,19 @@ public function getPriority(): int protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { $location = $this->configuration['location']; - $locationIndexes = []; + $locationIndices = []; foreach (['after_open', 'after_declare_strict'] as $possibleLocation) { $locationIndex = $this->findHeaderCommentInsertionIndex($tokens, $possibleLocation); - if (!isset($locationIndexes[$locationIndex]) || $possibleLocation === $location) { - $locationIndexes[$locationIndex] = $possibleLocation; + if (!isset($locationIndices[$locationIndex]) || $possibleLocation === $location) { + $locationIndices[$locationIndex] = $possibleLocation; continue; } } - foreach (array_values($locationIndexes) as $possibleLocation) { + foreach (array_values($locationIndices) as $possibleLocation) { // figure out where the comment should be placed $headerNewIndex = $this->findHeaderCommentInsertionIndex($tokens, $possibleLocation); diff --git a/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php b/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php index 6831c77dcc4..ec3ee8b79ae 100644 --- a/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php +++ b/src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php @@ -119,11 +119,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void continue; } - $indexesToClear = array_keys($sequenceFound); - array_pop($indexesToClear); // Preserve last semicolon - rsort($indexesToClear); + $indicesToClear = array_keys($sequenceFound); + array_pop($indicesToClear); // Preserve last semicolon + rsort($indicesToClear); - foreach ($indexesToClear as $index) { + foreach ($indicesToClear as $index) { $tokens->clearTokenAndMergeSurroundingWhitespace($index); } diff --git a/src/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixer.php b/src/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixer.php index cc7492f50ad..8da8cc0a3c7 100644 --- a/src/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixer.php +++ b/src/Fixer/DoctrineAnnotation/DoctrineAnnotationIndentationFixer.php @@ -168,7 +168,7 @@ private function isClosingLineWithMeaningfulContent(Tokens $tokens, int $index): } /** - * @param array> $annotationPositions Pairs of begin and end indexes of main annotations + * @param array> $annotationPositions Pairs of begin and end indices of main annotations */ private function indentationCanBeFixed(Tokens $tokens, int $newLineTokenIndex, array $annotationPositions): bool { diff --git a/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php b/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php index bc20074570f..2c767d06dcb 100644 --- a/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php +++ b/src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php @@ -128,14 +128,14 @@ private function fixClass(Tokens $tokens, int $index): void } $docCommentIndex = $index; - $propertyIndexes = $this->findNextUntypedPropertiesDeclaration($tokens, $docCommentIndex); + $propertyIndices = $this->findNextUntypedPropertiesDeclaration($tokens, $docCommentIndex); - if ([] === $propertyIndexes) { + if ([] === $propertyIndices) { continue; } $typeInfo = $this->resolveApplicableType( - $propertyIndexes, + $propertyIndices, $this->getAnnotationsFromDocComment('var', $tokens, $docCommentIndex) ); @@ -154,9 +154,9 @@ private function fixClass(Tokens $tokens, int $index): void [new Token([T_WHITESPACE, ' '])] ); - $tokens->insertAt(current($propertyIndexes), $newTokens); + $tokens->insertAt(current($propertyIndices), $newTokens); - $index = max($propertyIndexes) + \count($newTokens) + 1; + $index = max($propertyIndices) + \count($newTokens) + 1; $classEndIndex += \count($newTokens); } } @@ -194,10 +194,10 @@ private function findNextUntypedPropertiesDeclaration(Tokens $tokens, int $index } /** - * @param array $propertyIndexes + * @param array $propertyIndices * @param Annotation[] $annotations */ - private function resolveApplicableType(array $propertyIndexes, array $annotations): ?array + private function resolveApplicableType(array $propertyIndices, array $annotations): ?array { $propertyTypes = []; @@ -205,14 +205,14 @@ private function resolveApplicableType(array $propertyIndexes, array $annotation $propertyName = $annotation->getVariableName(); if (null === $propertyName) { - if (1 !== \count($propertyIndexes)) { + if (1 !== \count($propertyIndices)) { continue; } - $propertyName = key($propertyIndexes); + $propertyName = key($propertyIndices); } - if (!isset($propertyIndexes[$propertyName])) { + if (!isset($propertyIndices[$propertyName])) { continue; } @@ -227,7 +227,7 @@ private function resolveApplicableType(array $propertyIndexes, array $annotation $propertyTypes[$propertyName] = $typeInfo; } - if (\count($propertyTypes) !== \count($propertyIndexes)) { + if (\count($propertyTypes) !== \count($propertyIndices)) { return null; } diff --git a/src/Fixer/Import/GlobalNamespaceImportFixer.php b/src/Fixer/Import/GlobalNamespaceImportFixer.php index 2c8017592a9..dbc0ef7f644 100644 --- a/src/Fixer/Import/GlobalNamespaceImportFixer.php +++ b/src/Fixer/Import/GlobalNamespaceImportFixer.php @@ -201,8 +201,7 @@ private function importConstants(Tokens $tokens, array $useDeclarations): array } $analyzer = new TokensAnalyzer($tokens); - - $indexes = []; + $indices = []; for ($index = $tokens->count() - 1; $index >= 0; --$index) { $token = $tokens[$index]; @@ -237,10 +236,10 @@ private function importConstants(Tokens $tokens, array $useDeclarations): array continue; } - $indexes[] = $index; + $indices[] = $index; } - return $this->prepareImports($tokens, $indexes, $global, $other, true); + return $this->prepareImports($tokens, $indices, $global, $other, true); } /** @@ -259,8 +258,7 @@ private function importFunctions(Tokens $tokens, array $useDeclarations): array } $analyzer = new FunctionsAnalyzer(); - - $indexes = []; + $indices = []; for ($index = $tokens->count() - 1; $index >= 0; --$index) { $token = $tokens[$index]; @@ -288,10 +286,10 @@ private function importFunctions(Tokens $tokens, array $useDeclarations): array continue; } - $indexes[] = $index; + $indices[] = $index; } - return $this->prepareImports($tokens, $indexes, $global, $other, false); + return $this->prepareImports($tokens, $indices, $global, $other, false); } /** @@ -339,8 +337,7 @@ private function importClasses(Tokens $tokens, array $useDeclarations): array } $analyzer = new ClassyAnalyzer(); - - $indexes = []; + $indices = []; for ($index = $tokens->count() - 1; $index >= 0; --$index) { $token = $tokens[$index]; @@ -372,7 +369,7 @@ private function importClasses(Tokens $tokens, array $useDeclarations): array continue; } - $indexes[] = $index; + $indices[] = $index; } $imports = []; @@ -404,21 +401,21 @@ private function importClasses(Tokens $tokens, array $useDeclarations): array } } - return $imports + $this->prepareImports($tokens, $indexes, $global, $other, false); + return $imports + $this->prepareImports($tokens, $indices, $global, $other, false); } /** - * Removes the leading slash at the given indexes (when the name is not already used). + * Removes the leading slash at the given indices (when the name is not already used). * - * @param int[] $indexes + * @param int[] $indices * * @return array array keys contain the names that must be imported */ - private function prepareImports(Tokens $tokens, array $indexes, array $global, array $other, bool $caseSensitive): array + private function prepareImports(Tokens $tokens, array $indices, array $global, array $other, bool $caseSensitive): array { $imports = []; - foreach ($indexes as $index) { + foreach ($indices as $index) { $name = $tokens[$index]->getContent(); $checkName = $caseSensitive ? $name : strtolower($name); diff --git a/src/Fixer/Import/NoLeadingImportSlashFixer.php b/src/Fixer/Import/NoLeadingImportSlashFixer.php index 86f5c6764a7..a1bcc09a718 100644 --- a/src/Fixer/Import/NoLeadingImportSlashFixer.php +++ b/src/Fixer/Import/NoLeadingImportSlashFixer.php @@ -64,9 +64,9 @@ public function isCandidate(Tokens $tokens): bool protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { $tokensAnalyzer = new TokensAnalyzer($tokens); - $usesIndexes = $tokensAnalyzer->getImportUseIndexes(); + $usesIndices = $tokensAnalyzer->getImportUseIndexes(); - foreach ($usesIndexes as $idx) { + foreach ($usesIndices as $idx) { $nextTokenIdx = $tokens->getNextMeaningfulToken($idx); $nextToken = $tokens[$nextTokenIdx]; diff --git a/src/Fixer/Import/NoUnusedImportsFixer.php b/src/Fixer/Import/NoUnusedImportsFixer.php index 7fd72ca68e4..9033db7f173 100644 --- a/src/Fixer/Import/NoUnusedImportsFixer.php +++ b/src/Fixer/Import/NoUnusedImportsFixer.php @@ -77,17 +77,17 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void foreach ((new NamespacesAnalyzer())->getDeclarations($tokens) as $namespace) { $currentNamespaceUseDeclarations = []; - $currentNamespaceUseDeclarationIndexes = []; + $currentNamespaceUseDeclarationIndices = []; foreach ($useDeclarations as $useDeclaration) { if ($useDeclaration->getStartIndex() >= $namespace->getScopeStartIndex() && $useDeclaration->getEndIndex() <= $namespace->getScopeEndIndex()) { $currentNamespaceUseDeclarations[] = $useDeclaration; - $currentNamespaceUseDeclarationIndexes[$useDeclaration->getStartIndex()] = $useDeclaration->getEndIndex(); + $currentNamespaceUseDeclarationIndices[$useDeclaration->getStartIndex()] = $useDeclaration->getEndIndex(); } } foreach ($currentNamespaceUseDeclarations as $useDeclaration) { - if (!$this->isImportUsed($tokens, $namespace, $useDeclaration, $currentNamespaceUseDeclarationIndexes)) { + if (!$this->isImportUsed($tokens, $namespace, $useDeclaration, $currentNamespaceUseDeclarationIndices)) { $this->removeUseDeclaration($tokens, $useDeclaration); } } @@ -97,9 +97,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } /** - * @param array $ignoredIndexes indexes of the use statements themselves that should not be checked as being "used" + * @param array $ignoredIndices indices of the use statements themselves that should not be checked as being "used" */ - private function isImportUsed(Tokens $tokens, NamespaceAnalysis $namespace, NamespaceUseAnalysis $import, array $ignoredIndexes): bool + private function isImportUsed(Tokens $tokens, NamespaceAnalysis $namespace, NamespaceUseAnalysis $import, array $ignoredIndices): bool { $analyzer = new TokensAnalyzer($tokens); $gotoLabelAnalyzer = new GotoLabelAnalyzer(); @@ -130,8 +130,8 @@ private function isImportUsed(Tokens $tokens, NamespaceAnalysis $namespace, Name continue; } - if (isset($ignoredIndexes[$index])) { - $index = $ignoredIndexes[$index]; + if (isset($ignoredIndices[$index])) { + $index = $ignoredIndices[$index]; continue; } diff --git a/src/Fixer/Import/OrderedImportsFixer.php b/src/Fixer/Import/OrderedImportsFixer.php index 5c6199e6cde..b17e50dafd9 100644 --- a/src/Fixer/Import/OrderedImportsFixer.php +++ b/src/Fixer/Import/OrderedImportsFixer.php @@ -336,8 +336,8 @@ private function prepareNamespace(string $namespace): string */ private function getNewOrder(array $uses, Tokens $tokens): array { - $indexes = []; - $originalIndexes = []; + $indices = []; + $originalIndices = []; $lineEnding = $this->whitespacesConfig->getLineEnding(); for ($i = \count($uses) - 1; $i >= 0; --$i) { @@ -446,7 +446,7 @@ private function getNewOrder(array $uses, Tokens $tokens): array $namespace = Tokens::fromArray($namespaceTokens)->generateCode(); } - $indexes[$startIndex] = [ + $indices[$startIndex] = [ 'namespace' => $namespace, 'startIndex' => $startIndex, 'endIndex' => $index - 1, @@ -454,7 +454,7 @@ private function getNewOrder(array $uses, Tokens $tokens): array 'group' => $group, ]; - $originalIndexes[] = $startIndex; + $originalIndices[] = $startIndex; if ($index === $endIndex) { break; @@ -475,16 +475,16 @@ private function getNewOrder(array $uses, Tokens $tokens): array // Is sort types provided, sorting by groups and each group by algorithm if (null !== $this->configuration['imports_order']) { - // Grouping indexes by import type. + // Grouping indices by import type. $groupedByTypes = []; - foreach ($indexes as $startIndex => $item) { + foreach ($indices as $startIndex => $item) { $groupedByTypes[$item['importType']][$startIndex] = $item; } // Sorting each group by algorithm. - foreach ($groupedByTypes as $type => $groupIndexes) { - $groupedByTypes[$type] = $this->sortByAlgorithm($groupIndexes); + foreach ($groupedByTypes as $type => $groupIndices) { + $groupedByTypes[$type] = $this->sortByAlgorithm($groupIndices); } // Ordering groups @@ -497,34 +497,35 @@ private function getNewOrder(array $uses, Tokens $tokens): array } } } - $indexes = $sortedGroups; + + $indices = $sortedGroups; } else { // Sorting only by algorithm - $indexes = $this->sortByAlgorithm($indexes); + $indices = $this->sortByAlgorithm($indices); } $index = -1; $usesOrder = []; // Loop through the index but use original index order - foreach ($indexes as $v) { - $usesOrder[$originalIndexes[++$index]] = $v; + foreach ($indices as $v) { + $usesOrder[$originalIndices[++$index]] = $v; } return $usesOrder; } /** - * @param array[] $indexes + * @param array[] $indices */ - private function sortByAlgorithm(array $indexes): array + private function sortByAlgorithm(array $indices): array { if (self::SORT_ALPHA === $this->configuration['sort_algorithm']) { - uasort($indexes, [$this, 'sortAlphabetically']); + uasort($indices, [$this, 'sortAlphabetically']); } elseif (self::SORT_LENGTH === $this->configuration['sort_algorithm']) { - uasort($indexes, [$this, 'sortByLength']); + uasort($indices, [$this, 'sortByLength']); } - return $indexes; + return $indices; } } diff --git a/src/Fixer/LanguageConstruct/CombineConsecutiveIssetsFixer.php b/src/Fixer/LanguageConstruct/CombineConsecutiveIssetsFixer.php index cc53bfde3d7..ce09c125d52 100644 --- a/src/Fixer/LanguageConstruct/CombineConsecutiveIssetsFixer.php +++ b/src/Fixer/LanguageConstruct/CombineConsecutiveIssetsFixer.php @@ -113,11 +113,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } /** - * @param int[] $indexes + * @param int[] $indices */ - private function clearTokens(Tokens $tokens, array $indexes): void + private function clearTokens(Tokens $tokens, array $indices): void { - foreach ($indexes as $index) { + foreach ($indices as $index) { $tokens->clearTokenAndMergeSurroundingWhitespace($index); } } @@ -125,21 +125,21 @@ private function clearTokens(Tokens $tokens, array $indexes): void /** * @param int $index of T_ISSET * - * @return int[] indexes of meaningful tokens belonging to the isset statement + * @return int[] indices of meaningful tokens belonging to the isset statement */ private function getIssetInfo(Tokens $tokens, int $index): array { $openIndex = $tokens->getNextMeaningfulToken($index); $braceOpenCount = 1; - $meaningfulTokenIndexes = [$openIndex]; + $meaningfulTokenIndices = [$openIndex]; for ($i = $openIndex + 1;; ++$i) { if ($tokens[$i]->isWhitespace() || $tokens[$i]->isComment()) { continue; } - $meaningfulTokenIndexes[] = $i; + $meaningfulTokenIndices[] = $i; if ($tokens[$i]->equals(')')) { --$braceOpenCount; @@ -151,19 +151,19 @@ private function getIssetInfo(Tokens $tokens, int $index): array } } - return $meaningfulTokenIndexes; + return $meaningfulTokenIndices; } /** - * @param int[] $indexes + * @param int[] $indices * * @return Token[] */ - private function getTokenClones(Tokens $tokens, array $indexes): array + private function getTokenClones(Tokens $tokens, array $indices): array { $clones = []; - foreach ($indexes as $i) { + foreach ($indices as $i) { $clones[] = clone $tokens[$i]; } diff --git a/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php b/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php index c4795f57942..b38355801f1 100644 --- a/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php +++ b/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php @@ -84,21 +84,21 @@ private function fixNamespace(Tokens $tokens, int $index): int $tillIndex = $tokens->getPrevMeaningfulToken($tillIndex); - $spaceIndexes = []; + $spaceIndices = []; for (; $index <= $tillIndex; ++$index) { if ($tokens[$index]->isGivenKind(T_WHITESPACE)) { - $spaceIndexes[] = $index; + $spaceIndices[] = $index; } elseif ($tokens[$index]->isComment()) { $tokens->clearAt($index); } } if ($tokens[$index - 1]->isWhitespace()) { - array_pop($spaceIndexes); + array_pop($spaceIndices); } - foreach ($spaceIndexes as $i) { + foreach ($spaceIndices as $i) { $tokens->clearAt($i); } diff --git a/src/Fixer/Operator/OperatorLinebreakFixer.php b/src/Fixer/Operator/OperatorLinebreakFixer.php index 54ab0cf1e67..73a3e64506f 100644 --- a/src/Fixer/Operator/OperatorLinebreakFixer.php +++ b/src/Fixer/Operator/OperatorLinebreakFixer.php @@ -171,23 +171,23 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void */ private function getExcludedIndices(Tokens $tokens): array { - $colonIndexes = []; + $colonIndices = []; foreach (ControlCaseStructuresAnalyzer::findControlStructures($tokens, [T_SWITCH]) as $analysis) { foreach ($analysis->getCases() as $case) { - $colonIndexes[] = $case->getColonIndex(); + $colonIndices[] = $case->getColonIndex(); } if ($analysis instanceof SwitchAnalysis) { $defaultAnalysis = $analysis->getDefaultAnalysis(); if (null !== $defaultAnalysis) { - $colonIndexes[] = $defaultAnalysis->getColonIndex(); + $colonIndices[] = $defaultAnalysis->getColonIndex(); } } } - return $colonIndexes; + return $colonIndices; } /** diff --git a/src/Fixer/Operator/TernaryOperatorSpacesFixer.php b/src/Fixer/Operator/TernaryOperatorSpacesFixer.php index e2a32330905..ef98a2bf7f8 100644 --- a/src/Fixer/Operator/TernaryOperatorSpacesFixer.php +++ b/src/Fixer/Operator/TernaryOperatorSpacesFixer.php @@ -147,23 +147,23 @@ private function belongsToAlternativeSyntax(Tokens $tokens, int $index): bool */ private function getColonIndicesForSwitch(Tokens $tokens): array { - $colonIndexes = []; + $colonIndices = []; foreach (ControlCaseStructuresAnalyzer::findControlStructures($tokens, [T_SWITCH]) as $analysis) { foreach ($analysis->getCases() as $case) { - $colonIndexes[] = $case->getColonIndex(); + $colonIndices[] = $case->getColonIndex(); } if ($analysis instanceof SwitchAnalysis) { $defaultAnalysis = $analysis->getDefaultAnalysis(); if (null !== $defaultAnalysis) { - $colonIndexes[] = $defaultAnalysis->getColonIndex(); + $colonIndices[] = $defaultAnalysis->getColonIndex(); } } } - return $colonIndexes; + return $colonIndices; } private function ensureWhitespaceExistence(Tokens $tokens, int $index, bool $after): void diff --git a/src/Fixer/Operator/TernaryToNullCoalescingFixer.php b/src/Fixer/Operator/TernaryToNullCoalescingFixer.php index 045d3f389ac..b5b5ea8c1da 100644 --- a/src/Fixer/Operator/TernaryToNullCoalescingFixer.php +++ b/src/Fixer/Operator/TernaryToNullCoalescingFixer.php @@ -64,9 +64,9 @@ public function isCandidate(Tokens $tokens): bool */ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { - $issetIndexes = array_keys($tokens->findGivenKind(T_ISSET)); + $issetIndices = array_keys($tokens->findGivenKind(T_ISSET)); - while ($issetIndex = array_pop($issetIndexes)) { + while ($issetIndex = array_pop($issetIndices)) { $this->fixIsset($tokens, $issetIndex); } } diff --git a/src/Fixer/PhpUnit/PhpUnitConstructFixer.php b/src/Fixer/PhpUnit/PhpUnitConstructFixer.php index 3539a7a9a7e..08916229b5f 100644 --- a/src/Fixer/PhpUnit/PhpUnitConstructFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitConstructFixer.php @@ -182,29 +182,29 @@ private function fixAssert(array $map, Tokens $tokens, int $index, string $metho return null; } - $sequenceIndexes = array_keys($sequence); + $sequenceIndices = array_keys($sequence); - if (!$functionsAnalyzer->isTheSameClassCall($tokens, $sequenceIndexes[0])) { + if (!$functionsAnalyzer->isTheSameClassCall($tokens, $sequenceIndices[0])) { return null; } - $sequenceIndexes[2] = $tokens->getNextMeaningfulToken($sequenceIndexes[1]); - $firstParameterToken = $tokens[$sequenceIndexes[2]]; + $sequenceIndices[2] = $tokens->getNextMeaningfulToken($sequenceIndices[1]); + $firstParameterToken = $tokens[$sequenceIndices[2]]; if (!$firstParameterToken->isNativeConstant()) { - return $sequenceIndexes[2]; + return $sequenceIndices[2]; } - $sequenceIndexes[3] = $tokens->getNextMeaningfulToken($sequenceIndexes[2]); + $sequenceIndices[3] = $tokens->getNextMeaningfulToken($sequenceIndices[2]); // return if first method argument is an expression, not value - if (!$tokens[$sequenceIndexes[3]]->equals(',')) { - return $sequenceIndexes[3]; + if (!$tokens[$sequenceIndices[3]]->equals(',')) { + return $sequenceIndices[3]; } - $tokens[$sequenceIndexes[0]] = new Token([T_STRING, $map[strtolower($firstParameterToken->getContent())]]); - $tokens->clearRange($sequenceIndexes[2], $tokens->getNextNonWhitespace($sequenceIndexes[3]) - 1); + $tokens[$sequenceIndices[0]] = new Token([T_STRING, $map[strtolower($firstParameterToken->getContent())]]); + $tokens->clearRange($sequenceIndices[2], $tokens->getNextNonWhitespace($sequenceIndices[3]) - 1); - return $sequenceIndexes[3]; + return $sequenceIndices[3]; } } diff --git a/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php b/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php index 39d6db8b7a5..271b1a60c20 100644 --- a/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php +++ b/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php @@ -129,8 +129,9 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn */ protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $endIndex): void { - $anonymousClassIndexes = []; + $anonymousClassIndices = []; $tokenAnalyzer = new TokensAnalyzer($tokens); + for ($index = $startIndex; $index < $endIndex; ++$index) { if (!$tokens[$index]->isClassy() || !$tokenAnalyzer->isAnonymousClass($index)) { continue; @@ -139,12 +140,12 @@ protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $en $openingBraceIndex = $tokens->getNextTokenOfKind($index, ['{']); $closingBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $openingBraceIndex); - $anonymousClassIndexes[$closingBraceIndex] = $openingBraceIndex; + $anonymousClassIndices[$closingBraceIndex] = $openingBraceIndex; } for ($index = $endIndex - 1; $index > $startIndex; --$index) { - if (isset($anonymousClassIndexes[$index])) { - $index = $anonymousClassIndexes[$index]; + if (isset($anonymousClassIndices[$index])) { + $index = $anonymousClassIndices[$index]; continue; } diff --git a/src/Fixer/Phpdoc/PhpdocOrderFixer.php b/src/Fixer/Phpdoc/PhpdocOrderFixer.php index a33c1e9284a..b9eac52a467 100644 --- a/src/Fixer/Phpdoc/PhpdocOrderFixer.php +++ b/src/Fixer/Phpdoc/PhpdocOrderFixer.php @@ -119,7 +119,7 @@ private function moveParamAnnotations(string $content): string // move stuff about if required foreach ($others as $other) { if ($other->getStart() < $end) { - // we're doing this to maintain the original line indexes + // we're doing this to maintain the original line indices $line->setContent($line->getContent().$other->getContent()); $other->remove(); } @@ -155,7 +155,7 @@ private function moveReturnAnnotations(string $content): string // move stuff about if required foreach (array_reverse($others) as $other) { if ($other->getEnd() > $start) { - // we're doing this to maintain the original line indexes + // we're doing this to maintain the original line indices $line->setContent($other->getContent().$line->getContent()); $other->remove(); } diff --git a/src/Indicator/PhpUnitTestCaseIndicator.php b/src/Indicator/PhpUnitTestCaseIndicator.php index 21d089b8784..cdccb8eda90 100644 --- a/src/Indicator/PhpUnitTestCaseIndicator.php +++ b/src/Indicator/PhpUnitTestCaseIndicator.php @@ -56,7 +56,7 @@ public function isPhpUnitClass(Tokens $tokens, int $index): bool } /** - * @return \Generator array of [int start, int end] indexes from sooner to later classes + * @return \Generator array of [int start, int end] indices from sooner to later classes */ public function findPhpUnitClasses(Tokens $tokens): \Generator { diff --git a/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php b/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php index 0bc0a9dffa9..964f35c1231 100644 --- a/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php +++ b/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php @@ -36,7 +36,7 @@ public function countArguments(Tokens $tokens, int $openParenthesis, int $closeP } /** - * Returns start and end token indexes of arguments. + * Returns start and end token indices of arguments. * * Returns an array with each key being the first token of an * argument and the value the last. Including non-function tokens diff --git a/src/Tokenizer/Analyzer/NamespaceUsesAnalyzer.php b/src/Tokenizer/Analyzer/NamespaceUsesAnalyzer.php index e31985668fa..94b12054a67 100644 --- a/src/Tokenizer/Analyzer/NamespaceUsesAnalyzer.php +++ b/src/Tokenizer/Analyzer/NamespaceUsesAnalyzer.php @@ -31,9 +31,9 @@ final class NamespaceUsesAnalyzer public function getDeclarationsFromTokens(Tokens $tokens): array { $tokenAnalyzer = new TokensAnalyzer($tokens); - $useIndexes = $tokenAnalyzer->getImportUseIndexes(); + $useIndices = $tokenAnalyzer->getImportUseIndexes(); - return $this->getDeclarations($tokens, $useIndexes); + return $this->getDeclarations($tokens, $useIndices); } /** @@ -55,11 +55,11 @@ public function getDeclarationsInNamespace(Tokens $tokens, NamespaceAnalysis $na /** * @return NamespaceUseAnalysis[] */ - private function getDeclarations(Tokens $tokens, array $useIndexes): array + private function getDeclarations(Tokens $tokens, array $useIndices): array { $uses = []; - foreach ($useIndexes as $index) { + foreach ($useIndices as $index) { $endIndex = $tokens->getNextTokenOfKind($index, [';', [T_CLOSE_TAG]]); $analysis = $this->parseDeclaration($tokens, $index, $endIndex); diff --git a/src/Tokenizer/Tokens.php b/src/Tokenizer/Tokens.php index 567a1845dd1..aa3d3abe99c 100644 --- a/src/Tokenizer/Tokens.php +++ b/src/Tokenizer/Tokens.php @@ -145,13 +145,13 @@ public static function detectBlockType(Token $token): ?array * Create token collection from array. * * @param Token[] $array the array to import - * @param ?bool $saveIndexes save the numeric indexes used in the original array, default is yes + * @param ?bool $saveIndices save the numeric indices used in the original array, default is yes */ - public static function fromArray($array, $saveIndexes = null): self + public static function fromArray($array, $saveIndices = null): self { $tokens = new self(\count($array)); - if (null === $saveIndexes || $saveIndexes) { + if (null === $saveIndices || $saveIndices) { foreach ($array as $key => $val) { $tokens[$key] = $val; } @@ -478,7 +478,7 @@ public function generateCode(): string } /** - * Generate code from tokens between given indexes. + * Generate code from tokens between given indices. * * @param int $start start index * @param int $end end index @@ -832,7 +832,7 @@ public function insertAt(int $index, $items): void * - should we deprecate `insertAt` method ? * * The `$slices` parameter is an assoc array, in which: - * - index: starting point for inserting of individual slice, with indexes being relatives to original array collection before any Token inserted + * - index: starting point for inserting of individual slice, with indices being relatives to original array collection before any Token inserted * - value under index: a slice of Tokens to be inserted * * @internal diff --git a/src/Tokenizer/TokensAnalyzer.php b/src/Tokenizer/TokensAnalyzer.php index 9765096deec..b69254504b1 100644 --- a/src/Tokenizer/TokensAnalyzer.php +++ b/src/Tokenizer/TokensAnalyzer.php @@ -47,7 +47,7 @@ public function __construct(Tokens $tokens) } /** - * Get indexes of methods and properties in classy code (classes, interfaces and traits). + * Get indices of methods and properties in classy code (classes, interfaces and traits). * * @return array[] */ @@ -68,7 +68,7 @@ public function getClassyElements(): array } /** - * Get indexes of namespace uses. + * Get indices of namespace uses. * * @param bool $perNamespace Return namespace uses per namespace *