Skip to content

Commit

Permalink
chore: narrow PHPDoc types (#7979)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed May 2, 2024
1 parent ac1e370 commit 9136411
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 35 deletions.
30 changes: 0 additions & 30 deletions dev-tools/phpstan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@
'count' => 3,
'path' => __DIR__ . '/../../src/Fixer/Basic/PsrAutoloadingFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#2 \\$tokens of method PhpCsFixer\\\\Tokenizer\\\\Tokens\\:\\:getPrevTokenOfKind\\(\\) expects list\\<array\\{int\\}\\|PhpCsFixer\\\\Tokenizer\\\\Token\\|string\\>, list\\<list\\<int\\>\\|string\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Casing/NativeTypeDeclarationCasingFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'elements\' on array\\{index\\: int, open\\: int\\|null, close\\: int\\<0, max\\>, elements\\: list\\<array\\{token\\: PhpCsFixer\\\\Tokenizer\\\\Token, type\\: \'case\'\\|\'const\'\\|\'method\'\\|\'property\'\\|\'trait_import\', index\\: int, start\\: int, end\\: int\\}\\>\\}\\|false\\.$#',
'count' => 1,
Expand Down Expand Up @@ -366,36 +361,11 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/ControlStructure/IncludeFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$sequence of method PhpCsFixer\\\\Tokenizer\\\\Tokens\\:\\:findSequence\\(\\) expects non\\-empty\\-list\\<array\\{0\\: int, 1\\?\\: string\\}\\|PhpCsFixer\\\\Tokenizer\\\\Token\\|string\\>, array\\<int, list\\<int\\|string\\>\\|string\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$possibleKind of method PhpCsFixer\\\\Tokenizer\\\\Token\\:\\:isGivenKind\\(\\) expects list\\<int\\>\\|int, list\\<int\\|string\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/ControlStructure/YodaStyleFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'end\' on array\\{indices\\: list\\<int\\>, secondArgument\\?\\: int, levels\\: int, end\\: int\\}\\|true\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'indices\' on array\\{indices\\: list\\<int\\>, secondArgument\\?\\: int, levels\\: int, end\\: int\\}\\|true\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array\\<string, array\\<int, int\\>\\|int\\>\\|bool given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#2 \\$dirnameInfoArray of method PhpCsFixer\\\\Fixer\\\\FunctionNotation\\\\CombineNestedDirnameFixer\\:\\:combineDirnames\\(\\) expects list\\<array\\{indices\\: list\\<int\\>, secondArgument\\?\\: int, levels\\: int, end\\: int\\}\\>, non\\-empty\\-list\\<array\\{indices\\: list\\<int\\>, secondArgument\\?\\: int, levels\\: int, end\\: int\\}\\|true\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\FunctionNotation\\\\ImplodeCallFixer\\:\\:getArgumentIndices\\(\\) should return array\\<int, int\\> but returns array\\<int\\|string, int\\|null\\>\\.$#',
'count' => 1,
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Casing/NativeTypeDeclarationCasingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ final class NativeTypeDeclarationCasingFixer extends AbstractFixer
private FunctionsAnalyzer $functionsAnalyzer;

/**
* @var list<list<int>|string>
* @var list<array{int}|string>
*/
private array $beforePropertyTypeTokens;

Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ControlStructure/SimplifiedIfReturnFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
final class SimplifiedIfReturnFixer extends AbstractFixer
{
/**
* @var list<array{isNegative: bool, sequence: array<int, list<int|string>|string>}>
* @var list<array{isNegative: bool, sequence: non-empty-list<array{0: int, 1?: string}|string>}>
*/
private array $sequences = [
[
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
$dirnameInfo = $this->getDirnameInfo($tokens, $index);

if (!$dirnameInfo) {
if (false === $dirnameInfo) {
continue;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
* @param int $index Index of `dirname`
* @param null|int $firstArgumentEndIndex Index of last token of first argument of `dirname` call
*
* @return array{indices: list<int>, secondArgument?: int, levels: int, end: int}|bool `false` when it is not a (supported) `dirname` call, an array with info about the dirname call otherwise
* @return array{indices: list<int>, secondArgument?: int, levels: int, end: int}|false `false` when it is not a (supported) `dirname` call, an array with info about the dirname call otherwise
*/
private function getDirnameInfo(Tokens $tokens, int $index, ?int $firstArgumentEndIndex = null)
{
Expand Down Expand Up @@ -189,7 +189,7 @@ private function getDirnameInfo(Tokens $tokens, int $index, ?int $firstArgumentE
}

/**
* @param list<array{indices: list<int>, secondArgument?: int, levels: int, end: int}> $dirnameInfoArray
* @param non-empty-list<array{indices: list<int>, secondArgument?: int, levels: int, end: int}> $dirnameInfoArray
*/
private function combineDirnames(Tokens $tokens, array $dirnameInfoArray): void
{
Expand Down

0 comments on commit 9136411

Please sign in to comment.