Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Rules/Functions/MissingFunctionReturnTypehintRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function processNode(Node $node, Scope $scope): array
/**
* With the fixMissingReturnTypes feature toggle, the errors are fixed with the returned type.
*
* @param list<array{string, string, string|null}> $errors
* @param list<array{string, 'missingType.return'|'missingType.iterableValue', string|null}> $errors
* @return list<IdentifierRuleError>
*/
private function createReturnTypeErrors(FunctionReturnStatementsNode $node, array $errors): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function processNode(Node $node, Scope&CollectedDataEmitter $scope): arra
}

/**
* @param list<array{string, string, string|null}> $errors
* @param list<array{string, 'missingType.return'|'missingType.iterableValue', string|null}> $errors
* @return list<IdentifierRuleError>
*/
private function processFixableErrors(MethodReturnStatementsNode $node, Scope&CollectedDataEmitter $scope, array $errors): array
Expand Down Expand Up @@ -179,7 +179,7 @@ private function processFixableErrors(MethodReturnStatementsNode $node, Scope&Co
}

/**
* @param array{string, string, string|null} $error
* @param array{string, 'missingType.return'|'missingType.iterableValue', string|null} $error
* @return RuleErrorBuilder<IdentifierRuleError>
*/
private static function buildError(array $error): RuleErrorBuilder
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/MissingReturnTypeCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* Not registered as a collector, the data is emitted by the rules for missing return types.
*
* @implements Collector<never, array{key: string, traitMethod: string|null, class: string|null, overrides: list<string>, overridable: bool, returnInfo: array{values: string, void: bool, returnsValue: bool}|null, parentReturnType: string|false|null, parentNativeReturnType: string|false|null, nativeReturnType: string|false|null, fixedNatively: bool, errors: list<array{string, string, string|null}>, file: string, fileDescription: string, line: int, startPos: int, endPos: int}>
* @implements Collector<never, array{key: string, traitMethod: string|null, class: string|null, overrides: list<string>, overridable: bool, returnInfo: array{values: string, void: bool, returnsValue: bool}|null, parentReturnType: string|false|null, parentNativeReturnType: string|false|null, nativeReturnType: string|false|null, fixedNatively: bool, errors: list<array{string, 'missingType.return'|'missingType.iterableValue', string|null}>, file: string, fileDescription: string, line: int, startPos: int, endPos: int}>
*/
final class MissingReturnTypeCollector implements Collector
{
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/MissingReturnTypeFixRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* so that \$this is static. Its return type covers what it returns in all of them, they share one fix.
*
* @phpstan-import-type ReturnInfo from MissingReturnTypeFixer
* @phpstan-type Record array{key: string, traitMethod: string|null, class: string|null, overrides: list<string>, overridable: bool, returnInfo: array{values: string, void: bool, returnsValue: bool}|null, parentReturnType: string|false|null, parentNativeReturnType: string|false|null, nativeReturnType: string|false|null, fixedNatively: bool, errors: list<array{string, string, string|null}>, file: string, fileDescription: string, line: int, startPos: int, endPos: int}
* @phpstan-type Record array{key: string, traitMethod: string|null, class: string|null, overrides: list<string>, overridable: bool, returnInfo: array{values: string, void: bool, returnsValue: bool}|null, parentReturnType: string|false|null, parentNativeReturnType: string|false|null, nativeReturnType: string|false|null, fixedNatively: bool, errors: list<array{string, 'missingType.return'|'missingType.iterableValue', string|null}>, file: string, fileDescription: string, line: int, startPos: int, endPos: int}
* @implements Rule<CollectedDataNode>
*/
#[RegisteredRule(level: 6)]
Expand Down
5 changes: 3 additions & 2 deletions src/Rules/TooWideTypehints/OverridableMemberHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* of the type nobody uses.
*
* @phpstan-import-type Plan from TooWideReturnTypeFixer
* @phpstan-import-type MemberError from TooWideTypeCheck
*/
#[AutowiredService]
final class OverridableMemberHelper
Expand Down Expand Up @@ -123,7 +124,7 @@ public function findOverriddenPropertyHooks(ClassReflection $classReflection, st
/**
* @param self::KIND_* $kind
* @param list<int> $usedMembers the members of the type the member uses itself
* @param list<array{string, string, string|null}> $memberErrors message, identifier and tip for each member of the type
* @param list<MemberError> $memberErrors message, identifier and tip for each member of the type
* @param string|null $usedMembersTip tip for the errors with %s for the used members, or void
* @param list<string> $memberDescriptions the members of the type in $usedMembersTip
* @param bool $ownOnly whether only the members the member uses itself are not reported, in an open project
Expand Down Expand Up @@ -174,7 +175,7 @@ public function emitDeclaration(
* emitDeclaration() of the return type of a method, with the plan of its fix.
*
* @param list<int> $usedMembers
* @param list<array{string, string, string|null}> $memberErrors
* @param list<MemberError> $memberErrors
* @param array{plan: Plan, nativeUsed: list<int>, startPos: int, endPos: int}|null $fix
*/
public function emitReturnTypeDeclaration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function sprintf;

/**
* @phpstan-import-type MemberError from TooWideTypeCheck
* @implements Rule<MethodReturnStatementsNode>
*/
#[RegisteredRule(level: 4)]
Expand Down Expand Up @@ -135,7 +136,7 @@ public function processNode(Node $node, Scope&CollectedDataEmitter $scope): arra
}

/**
* @param array{list<int>, list<array{string, string, string|null}>} $result
* @param array{list<int>, list<MemberError>} $result
*/
private function emitDeclaration(MethodReturnStatementsNode $node, Scope&CollectedDataEmitter $scope, array $result, bool $ownOnly): void
{
Expand Down
5 changes: 4 additions & 1 deletion src/Rules/TooWideTypehints/TooWideParameterOutTypeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use function lcfirst;
use function sprintf;

/**
* @phpstan-import-type MemberError from TooWideTypeCheck
*/
#[AutowiredService]
final class TooWideParameterOutTypeCheck
{
Expand Down Expand Up @@ -84,7 +87,7 @@ public function check(
* @param list<ExecutionEndNode> $executionEnds
* @param list<ReturnStatement> $returnStatements
* @param list<ExtendedParameterReflection> $parameters
* @return array<int, array{list<int>, list<array{string, string, string|null}>}>
* @return array<int, array{list<int>, list<MemberError>}>
*/
public function createOverridableErrors(
array $executionEnds,
Expand Down
7 changes: 4 additions & 3 deletions src/Rules/TooWideTypehints/TooWideTypeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

/**
* @phpstan-import-type Plan from TooWideReturnTypeFixer
* @phpstan-type MemberError array{string, 'return.tooWideBool'|'return.unusedType'|'paramOut.tooWideBool'|'paramOut.unusedType'|'parameterByRef.tooWideBool'|'parameterByRef.unusedType'|'throws.unusedType', string|null}
*/
#[AutowiredService]
final class TooWideTypeCheck
Expand Down Expand Up @@ -376,7 +377,7 @@ private function createReturnTypeFix(
* reports when neither the method nor the methods overriding it return them: the members the method returns
* itself and the error for each member. Null when the method has nothing to report.
*
* @return array{list<int>, list<array{string, string, string|null}>}|null
* @return array{list<int>, list<MemberError>}|null
*/
public function createOverridableReturnTypeErrors(
MethodReturnStatementsNode $node,
Expand Down Expand Up @@ -697,7 +698,7 @@ public function checkParameterOutType(
* Like createOverridableReturnTypeErrors(), for the type of a parameter passed by reference after the call.
*
* @param 'paramOut'|'parameterByRef' $identifierPart
* @return array{list<int>, list<array{string, string, string|null}>}|null
* @return array{list<int>, list<MemberError>}|null
*/
public function createOverridableParameterOutTypeErrors(
Type $parameterOutType,
Expand Down Expand Up @@ -930,7 +931,7 @@ private function getUsedMembers(Type $declaredType, array $members, Type $actual
*
* @param list<Type> $members
* @param 'return'|'paramOut'|'parameterByRef' $identifierPart
* @return list<array{string, string, string|null}> message, identifier, tip
* @return list<MemberError>
*/
private function createMemberErrors(
Type $declaredType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

/**
* @phpstan-import-type Plan from TooWideReturnTypeFixer
* @phpstan-import-type MemberError from TooWideTypeCheck
*
* Not registered as a collector, the data is emitted with OverridableMemberHelper::emitDeclaration().
*
* @implements Collector<never, array{kind: string, class: string, member: string, slot: int, file: string|null, fileDescription: string|null, line: int, used: list<int>, errors: list<array{string, string, string|null}>, usedMembersTip: string|null, memberDescriptions: list<string>, ownOnly: bool, fix: array{plan: Plan, nativeUsed: list<int>, startPos: int, endPos: int}|null}>
* @implements Collector<never, array{kind: string, class: string, member: string, slot: int, file: string|null, fileDescription: string|null, line: int, used: list<int>, errors: list<MemberError>, usedMembersTip: string|null, memberDescriptions: list<string>, ownOnly: bool, fix: array{plan: Plan, nativeUsed: list<int>, startPos: int, endPos: int}|null}>
*/
final class TooWideTypeInOverridableMemberCollector implements Collector
{
Expand Down
Loading