Skip to content

Commit

Permalink
Merge branch 'master' into depr
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Mar 12, 2024
2 parents 5bc794a + ffce76b commit dcc897f
Show file tree
Hide file tree
Showing 36 changed files with 581 additions and 183 deletions.
65 changes: 0 additions & 65 deletions dev-tools/phpstan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Console/ConfigurationResolver.php',
];
$ignoreErrors[] = [
'message' => '#^Binary operation "\\+" between int and string results in an error\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/DocBlock/TypeExpression.php',
];
$ignoreErrors[] = [
'message' => '#^Foreach overwrites \\$token with its value variable\\.$#',
'count' => 1,
Expand Down Expand Up @@ -41,21 +36,11 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/CastNotation/NoShortBoolCastFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Argument of an invalid type string supplied for foreach, only iterables are supported\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/FullyQualifiedStrictTypesFixer.php',
];
$ignoreErrors[] = [
'message' => '#^For loop initial assignment overwrites variable \\$index\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/GlobalNamespaceImportFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$array of function array_reverse expects array, string given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/GlobalNamespaceImportFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$k might not be defined\\.$#',
'count' => 1,
Expand Down Expand Up @@ -91,26 +76,11 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/PhpUnit/PhpUnitConstructFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Argument of an invalid type string supplied for foreach, only iterables are supported\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Argument of an invalid type string supplied for foreach, only iterables are supported\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Phpdoc/PhpdocToCommentFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Foreach overwrites \\$index with its key variable\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Phpdoc/PhpdocTrimConsecutiveBlankLineSeparationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Argument of an invalid type string supplied for foreach, only iterables are supported\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$end might not be defined\\.$#',
'count' => 2,
Expand All @@ -126,36 +96,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Whitespace/StatementIndentationFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Preg\\:\\:match\\(\\) never assigns null to &\\$matches so it can be removed from the by\\-ref type\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Preg.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Preg\\:\\:matchAll\\(\\) never assigns null to &\\$matches so it can be removed from the by\\-ref type\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Preg.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Preg\\:\\:replace\\(\\) never assigns null to &\\$count so it can be removed from the by\\-ref type\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Preg.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Preg\\:\\:replaceCallback\\(\\) never assigns null to &\\$count so it can be removed from the by\\-ref type\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Preg.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter &\\$matches by\\-ref type of method PhpCsFixer\\\\Preg\\:\\:match\\(\\) expects array\\<string\\>\\|null, \\(int is int \\? array\\<array\\<int, int\\<\\-1, max\\>\\|string\\>\\> \\: \\(int is int \\? array\\<string\\|null\\> \\: \\(int is int \\? array\\<array\\<int, int\\|string\\|null\\>\\> \\: array\\<string\\>\\)\\)\\) given\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../src/Preg.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter &\\$matches by\\-ref type of method PhpCsFixer\\\\Preg\\:\\:matchAll\\(\\) expects array\\<string\\>\\|null, \\(int is int \\? array\\<array\\<int, string\\>\\> \\: \\(int is int \\? array\\<int, array\\<string\\>\\> \\: \\(int is int \\? array\\<array\\<int, array\\<int, int\\|string\\>\\>\\> \\: \\(int is int \\? array\\<int, array\\<array\\<int, int\\|string\\>\\>\\> \\: \\(int is int \\? array\\<array\\<int, string\\|null\\>\\> \\: \\(int is int \\? array\\<int, array\\<string\\|null\\>\\> \\: \\(int is int \\? array\\<int, array\\<array\\<int, int\\|string\\|null\\>\\>\\> \\: array\\)\\)\\)\\)\\)\\)\\) given\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../src/Preg.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 @@ -166,11 +106,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/StdinFileInfo.php',
];
$ignoreErrors[] = [
'message' => '#^PHPDoc tag @var with type array\\<int, string\\> is not subtype of type string\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Tokenizer/Analyzer/DataProviderAnalyzer.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
1 change: 0 additions & 1 deletion doc/ruleSets/PhpCsFixerRisky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Rules

``['sets' => ['@all']]``

- `no_unreachable_default_argument_value <./../rules/function_notation/no_unreachable_default_argument_value.rst>`_
- `no_unset_on_property <./../rules/language_construct/no_unset_on_property.rst>`_
- `php_unit_data_provider_name <./../rules/php_unit/php_unit_data_provider_name.rst>`_
- `php_unit_data_provider_return_type <./../rules/php_unit/php_unit_data_provider_return_type.rst>`_
Expand Down
5 changes: 0 additions & 5 deletions doc/ruleSets/SymfonyRisky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,3 @@ Rules
- `string_length_to_empty <./../rules/string_notation/string_length_to_empty.rst>`_
- `string_line_ending <./../rules/string_notation/string_line_ending.rst>`_
- `ternary_to_elvis_operator <./../rules/operator/ternary_to_elvis_operator.rst>`_

Disabled rules
--------------

- `no_unreachable_default_argument_value <./../rules/function_notation/no_unreachable_default_argument_value.rst>`_
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The rule is part of the following rule sets:
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PSR12:risky <./../../ruleSets/PSR12Risky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

References
----------
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/AbstractPhpUnitFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final protected function getDocBlockIndex(Tokens $tokens, int $index): int
}

/**
* @param array<string> $preventingAnnotations
* @param list<string> $preventingAnnotations
*/
final protected function ensureIsDockBlockWithAnnotation(
Tokens $tokens,
Expand Down Expand Up @@ -115,7 +115,7 @@ private function createDocBlock(Tokens $tokens, int $docBlockIndex, string $anno
}

/**
* @param array<string> $preventingAnnotations
* @param list<string> $preventingAnnotations
*/
private function updateDocBlockIfNeeded(
Tokens $tokens,
Expand All @@ -137,7 +137,7 @@ private function updateDocBlockIfNeeded(
}

/**
* @return array<Line>
* @return list<Line>
*/
private function addInternalAnnotation(DocBlock $docBlock, Tokens $tokens, int $docBlockIndex, string $annotation): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Alias/PowToExponentiationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

/**
* @return array<int[]>
* @return list<array{int, int, int}>
*/
private function findPowCalls(Tokens $tokens): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

/**
* @return iterable<int, array<int>>
* @return iterable<int, array{int, int}>
*/
private function getYieldsFromToUnpack(Tokens $tokens): iterable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Casing/MagicConstantCasingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private function getMagicConstants(): array
}

/**
* @return array<int>
* @return list<int>
*/
private function getMagicConstantTokens(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private function fixInfiniteRecursion(Tokens $tokens, int $start, int $end): voi
* @param int $startIndex function/method start index
* @param int $bodyIndex function/method body index
*
* @return array{array<array<array{int, string}|int|string>>, array{3: false}}
* @return array{list<list<array{int, string}|int|string>>, array{3: false}}
*/
private function getWrapperMethodSequence(Tokens $tokens, string $method, int $startIndex, int $bodyIndex): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/OrderedClassElementsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private function getElements(Tokens $tokens, int $startIndex): array
}

/**
* @return array<string>|string type or array of type and name
* @return list<string>|string type or array of type and name
*/
private function detectElementType(Tokens $tokens, int $index)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/ClassNotation/OrderedTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private function isTypeSortable(TypeAnalysis $type): bool
}

/**
* @return array{0: array<string|string[]>, 1: string}
* @return array{0: list<string|string[]>, 1: string}
*/
private function collectDisjunctiveNormalFormTypes(string $type): array
{
Expand Down Expand Up @@ -336,9 +336,9 @@ private function collectUnionOrIntersectionTypes(string $type): array
}

/**
* @param array<string|string[]> $types
* @param list<string|string[]> $types
*
* @return array<string|string[]>
* @return list<string|string[]>
*/
private function runTypesThroughSortingAlgorithm(array $types): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ControlStructure/NoBreakCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private function getStructureEnd(Tokens $tokens, int $position): int
}

/**
* @return array<int>
* @return list<int>
*/
private static function getParenthesisedStructureKinds(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private function isClosingLineWithMeaningfulContent(Tokens $tokens, int $index):
}

/**
* @param array<array<int>> $annotationPositions Pairs of begin and end indices of main annotations
* @param list<array{int, int}> $annotationPositions Pairs of begin and end indices of main annotations
*/
private function indentationCanBeFixed(Tokens $tokens, int $newLineTokenIndex, array $annotationPositions): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/FunctionNotation/CombineNestedDirnameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private function getDirnameInfo(Tokens $tokens, int $index, ?int $firstArgumentE
}

/**
* @param array<array{indices: list<int>, secondArgument?: int, levels: int, end: int}> $dirnameInfoArray
* @param list<array{indices: list<int>, secondArgument?: int, levels: int, end: int}> $dirnameInfoArray
*/
private function combineDirnames(Tokens $tokens, array $dirnameInfoArray): void
{
Expand Down
6 changes: 2 additions & 4 deletions src/Fixer/FunctionNotation/NoSpacesAfterFunctionNameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,16 @@ private function fixFunctionCall(Tokens $tokens, int $index): void
}

/**
* @return array<list<int>|string>
* @return list<array{int}|string>
*/
private function getBraceAfterVariableKinds(): array
{
static $tokens = [
return [
')',
']',
[CT::T_DYNAMIC_VAR_BRACE_CLOSE],
[CT::T_ARRAY_INDEX_CURLY_BRACE_CLOSE],
];

return $tokens;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/LanguageConstruct/NoUnsetOnPropertyFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

/**
* @return array<array<string, bool|int>>
* @return list<array<string, bool|int>>
*/
private function getUnsetsInfo(Tokens $tokens, int $index): array
{
Expand Down Expand Up @@ -144,7 +144,7 @@ private function isProperty(Tokens $tokens, int $index, int $endIndex): bool
}

/**
* @param array<array<string, bool|int>> $unsetsInfo
* @param list<array<string, bool|int>> $unsetsInfo
*/
private function isAnyUnsetToTransform(array $unsetsInfo): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Operator/BinaryOperatorSpacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ final class BinaryOperatorSpacesFixer extends AbstractFixer implements Configura
private int $currentLevel;

/**
* @var array<null|string>
* @var list<null|string>
*/
private static array $allowedValues = [
self::ALIGN,
Expand Down

0 comments on commit dcc897f

Please sign in to comment.