Skip to content

Commit

Permalink
chore: rename variables (#7847)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored Feb 19, 2024
1 parent 0edbfb9 commit 8794475
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 27 deletions.
15 changes: 0 additions & 15 deletions dev-tools/phpstan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/CastNotation/NoShortBoolCastFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Foreach overwrites \\$pos with its value variable\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php',
];
$ignoreErrors[] = [
'message' => '#^For loop initial assignment overwrites variable \\$index\\.$#',
'count' => 1,
Expand Down Expand Up @@ -101,11 +96,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Whitespace/StatementIndentationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^For loop initial assignment overwrites variable \\$i\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Whitespace/StatementIndentationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$className \\(string\\) of method PhpCsFixer\\\\StdinFileInfo\\:\\:getFileInfo\\(\\) should be contravariant with parameter \\$class \\(string\\|null\\) of method SplFileInfo\\:\\:getFileInfo\\(\\)$#',
'count' => 1,
Expand All @@ -116,11 +106,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/StdinFileInfo.php',
];
$ignoreErrors[] = [
'message' => '#^Foreach overwrites \\$key with its key variable\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Tokenizer/Tokens.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$array \\(array\\<int, PhpCsFixer\\\\Tokenizer\\\\Token\\>\\) of method PhpCsFixer\\\\Tokenizer\\\\Tokens\\:\\:fromArray\\(\\) should be contravariant with parameter \\$array \\(array\\<int, mixed\\>\\) of method SplFixedArray\\<PhpCsFixer\\\\Tokenizer\\\\Token\\>\\:\\:fromArray\\(\\)$#',
'count' => 1,
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/ClassNotation/OrderedClassElementsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public function configure(array $configuration): void
parent::configure($configuration);

$this->typePosition = [];
$pos = 0;
$position = 0;

foreach ($this->configuration['order'] as $type) {
$this->typePosition[$type] = $pos++;
$this->typePosition[$type] = $position++;
}

foreach (self::$typeHierarchy as $type => $parents) {
Expand Down
12 changes: 6 additions & 6 deletions src/Fixer/Whitespace/StatementIndentationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,22 +735,22 @@ private function isCommentWithFixableIndentation(Tokens $tokens, int $index): bo

$firstCommentIndex = $index;
while (true) {
$i = $this->getSiblingContinuousSingleLineComment($tokens, $firstCommentIndex, false);
if (null === $i) {
$firstCommentCandidateIndex = $this->getSiblingContinuousSingleLineComment($tokens, $firstCommentIndex, false);
if (null === $firstCommentCandidateIndex) {
break;
}

$firstCommentIndex = $i;
$firstCommentIndex = $firstCommentCandidateIndex;
}

$lastCommentIndex = $index;
while (true) {
$i = $this->getSiblingContinuousSingleLineComment($tokens, $lastCommentIndex, true);
if (null === $i) {
$lastCommentCandidateIndex = $this->getSiblingContinuousSingleLineComment($tokens, $lastCommentIndex, true);
if (null === $lastCommentCandidateIndex) {
break;
}

$lastCommentIndex = $i;
$lastCommentIndex = $lastCommentCandidateIndex;
}

if ($firstCommentIndex === $lastCommentIndex) {
Expand Down
8 changes: 4 additions & 4 deletions src/Tokenizer/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,10 @@ public function findSequence(array $sequence, int $start = 0, ?int $end = null,

// remove the first token from the sequence, so we can freely iterate through the sequence after a match to
// the first one is found
$key = array_key_first($sequence);
$firstCs = self::isKeyCaseSensitive($caseSensitive, $key);
$firstToken = $sequence[$key];
unset($sequence[$key]);
$firstKey = array_key_first($sequence);
$firstCs = self::isKeyCaseSensitive($caseSensitive, $firstKey);
$firstToken = $sequence[$firstKey];
unset($sequence[$firstKey]);

// begin searching for the first token in the sequence (start included)
$index = $start - 1;
Expand Down

0 comments on commit 8794475

Please sign in to comment.