Skip to content

Commit fd67793

Browse files
committed
Refactor - allow other message to be passed from getIterableTypesWithMissingValueTypehint
1 parent 6bcb8e8 commit fd67793

15 files changed

Lines changed: 40 additions & 50 deletions

src/Rules/Classes/LocalTypeAliasesCheck.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,9 @@ public function checkInTraitDefinitionContext(ClassReflection $reflection): arra
194194
continue;
195195
}
196196

197-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($resolvedType) as $iterableType) {
198-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
197+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($resolvedType) as $iterableTypeDescription) {
199198
$errors[] = RuleErrorBuilder::message(sprintf(
200-
'%s %s has type alias %s with no value type specified in iterable type %s.',
199+
'%s %s has type alias %s with no value type specified in %s.',
201200
$reflection->getClassTypeDescription(),
202201
$reflection->getDisplayName(),
203202
$aliasName,

src/Rules/Classes/MethodTagCheck.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@ private function checkMethodTypeInTraitDefinitionContext(ClassReflection $classR
190190
->build();
191191
}
192192

193-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($type) as $iterableType) {
194-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
193+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($type) as $iterableTypeDescription) {
195194
$errors[] = RuleErrorBuilder::message(sprintf(
196-
'%s %s has PHPDoc tag @method for method %s() %s with no value type specified in iterable type %s.',
195+
'%s %s has PHPDoc tag @method for method %s() %s with no value type specified in %s.',
197196
$classReflection->getClassTypeDescription(),
198197
$classReflection->getDisplayName(),
199198
$methodName,

src/Rules/Classes/MixinCheck.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ public function checkInTraitDefinitionContext(ClassReflection $classReflection):
7676
continue;
7777
}
7878

79-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($type) as $iterableType) {
80-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
79+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($type) as $iterableTypeDescription) {
8180
$errors[] = RuleErrorBuilder::message(sprintf(
82-
'%s %s has PHPDoc tag @mixin with no value type specified in iterable type %s.',
81+
'%s %s has PHPDoc tag @mixin with no value type specified in %s.',
8382
$classReflection->getClassTypeDescription(),
8483
$classReflection->getDisplayName(),
8584
$iterableTypeDescription,

src/Rules/Classes/PropertyTagCheck.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ private function checkPropertyTypeInTraitDefinitionContext(ClassReflection $clas
171171
->build();
172172
}
173173

174-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($type) as $iterableType) {
175-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
174+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($type) as $iterableTypeDescription) {
176175
$errors[] = RuleErrorBuilder::message(sprintf(
177-
'%s %s has PHPDoc tag %s for property $%s with no value type specified in iterable type %s.',
176+
'%s %s has PHPDoc tag %s for property $%s with no value type specified in %s.',
178177
$classReflection->getClassTypeDescription(),
179178
$classReflection->getDisplayName(),
180179
$tagName,

src/Rules/Constants/MissingClassConstantTypehintRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ private function processSingleConstant(ClassReflection $classReflection, string
5858
}
5959

6060
$errors = [];
61-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($constantType) as $iterableType) {
62-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
61+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($constantType) as $iterableTypeDescription) {
6362
$errors[] = RuleErrorBuilder::message(sprintf(
64-
'Constant %s::%s type has no value type specified in iterable type %s.',
63+
'Constant %s::%s type has no value type specified in %s.',
6564
$constantReflection->getDeclaringClass()->getDisplayName(),
6665
$constantName,
6766
$iterableTypeDescription,

src/Rules/Functions/MissingFunctionParameterTypehintRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ private function checkFunctionParameter(FunctionReflection $functionReflection,
8080
}
8181

8282
$messages = [];
83-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($parameterType) as $iterableType) {
84-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
83+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($parameterType) as $iterableTypeDescription) {
8584
$messages[] = RuleErrorBuilder::message(sprintf(
86-
'Function %s() has %s with no value type specified in iterable type %s.',
85+
'Function %s() has %s with no value type specified in %s.',
8786
$functionReflection->getName(),
8887
$parameterMessage,
8988
$iterableTypeDescription,

src/Rules/Functions/MissingFunctionReturnTypehintRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public function processNode(Node $node, Scope $scope): array
4848
}
4949

5050
$messages = [];
51-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($returnType) as $iterableType) {
52-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
53-
$messages[] = RuleErrorBuilder::message(sprintf('Function %s() return type has no value type specified in iterable type %s.', $functionReflection->getName(), $iterableTypeDescription))
51+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($returnType) as $iterableTypeDescription) {
52+
$messages[] = RuleErrorBuilder::message(sprintf('Function %s() return type has no value type specified in %s.', $functionReflection->getName(), $iterableTypeDescription))
5453
->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)
5554
->identifier('missingType.iterableValue')
5655
->build();

src/Rules/Methods/MissingMethodParameterTypehintRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ private function checkMethodParameter(MethodReflection $methodReflection, string
8181
}
8282

8383
$messages = [];
84-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($parameterType) as $iterableType) {
85-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
84+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($parameterType) as $iterableTypeDescription) {
8685
$messages[] = RuleErrorBuilder::message(sprintf(
87-
'Method %s::%s() has %s with no value type specified in iterable type %s.',
86+
'Method %s::%s() has %s with no value type specified in %s.',
8887
$methodReflection->getDeclaringClass()->getDisplayName(),
8988
$methodReflection->getName(),
9089
$parameterMessage,

src/Rules/Methods/MissingMethodReturnTypehintRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ public function processNode(Node $node, Scope $scope): array
5454
}
5555

5656
$messages = [];
57-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($returnType) as $iterableType) {
58-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
57+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($returnType) as $iterableTypeDescription) {
5958
$messages[] = RuleErrorBuilder::message(sprintf(
60-
'Method %s::%s() return type has no value type specified in iterable type %s.',
59+
'Method %s::%s() return type has no value type specified in %s.',
6160
$methodReflection->getDeclaringClass()->getDisplayName(),
6261
$methodReflection->getName(),
6362
$iterableTypeDescription,

src/Rules/Methods/MissingMethodSelfOutTypeRule.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ public function processNode(Node $node, Scope $scope): array
4545
$phpDocTagMessage = 'PHPDoc tag @phpstan-self-out';
4646

4747
$messages = [];
48-
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($selfOutType) as $iterableType) {
49-
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
48+
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($selfOutType) as $iterableTypeDescription) {
5049
$messages[] = RuleErrorBuilder::message(sprintf(
51-
'Method %s::%s() has %s with no value type specified in iterable type %s.',
50+
'Method %s::%s() has %s with no value type specified in %s.',
5251
$classReflection->getDisplayName(),
5352
$methodReflection->getName(),
5453
$phpDocTagMessage,

0 commit comments

Comments
 (0)