You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -181,10 +184,12 @@ private function analyzeWithTypehint($context, Type $phpTypeHint, array $docBloc
181
184
}
182
185
183
186
if ($docblockTypehint->getValueType() instanceof Mixed_) {
184
-
if ($contextinstanceof ReflectionParameter) {
185
-
returnsprintf('%s, parameter $%s type is "array". Please provide a more specific @param annotation. For instance: @param int[] $%s', $this->getContext($context), $context->getName(), $context->getName());
186
-
} else {
187
-
returnsprintf('%s, return type is "array". Please provide a more specific @return annotation. For instance: @return int[]', $this->getContext($context));
187
+
if (!$this->findExplicitMixedArray($context)) {
188
+
if ($contextinstanceof ReflectionParameter) {
189
+
returnsprintf('%s, parameter $%s type is "array". Please provide a more specific @param annotation in the docblock. For instance: @param int[] $%s. Use @param mixed[] $%s if this is really an array of mixed values.', $this->getContext($context), $context->getName(), $context->getName(), $context->getName());
190
+
} else {
191
+
returnsprintf('%s, return type is "array". Please provide a more specific @return annotation. For instance: @return int[]. Use @return mixed[] if this is really an array of mixed values.', $this->getContext($context));
192
+
}
188
193
}
189
194
}
190
195
}
@@ -193,6 +198,23 @@ private function analyzeWithTypehint($context, Type $phpTypeHint, array $docBloc
Copy file name to clipboardExpand all lines: tests/Rules/TypeHints/MissingTypeHintRuleInFunctionTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,14 @@ public function testCheckCatchedException()
64
64
[
65
65
'In function "mismatch", return type is type-hinted to "string" but the @return annotation says it is a "int". Please fix the @return annotation.',
66
66
52,
67
+
],
68
+
[
69
+
'In function "test8", parameter $any_array type is "array". Please provide a more specific @param annotation in the docblock. For instance: @param int[] $any_array. Use @param mixed[] $any_array if this is really an array of mixed values.',
70
+
70,
71
+
],
72
+
[
73
+
'In function "test8", return type is "array". Please provide a more specific @return annotation. For instance: @return int[]. Use @return mixed[] if this is really an array of mixed values.',
0 commit comments