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
Copy file name to clipboardExpand all lines: src/Rules/PhpDoc/ConditionalReturnTypeRuleHelper.php
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -77,14 +77,16 @@ public function check(ExtendedParametersAcceptor $acceptor): array
77
77
continue;
78
78
}
79
79
$templateTypes = [];
80
-
TypeTraverser::map($subjectType, staticfunction (Type$type, callable$traverse) use (&$templateTypes): Type {
81
-
if ($typeinstanceof TemplateType) {
82
-
$templateTypes[] = $type;
83
-
return$type;
84
-
}
85
-
86
-
return$traverse($type);
87
-
});
80
+
if ($subjectType->hasTemplateOrLateResolvableType()) {
81
+
TypeTraverser::map($subjectType, staticfunction (Type$type, callable$traverse) use (&$templateTypes): Type {
82
+
if ($typeinstanceof TemplateType) {
83
+
$templateTypes[] = $type;
84
+
return$type;
85
+
}
86
+
87
+
return$traverse($type);
88
+
});
89
+
}
88
90
89
91
if (count($templateTypes) === 0) {
90
92
$errors[] = RuleErrorBuilder::message(sprintf('Conditional return type uses subject type %s which is not part of PHPDoc @template tags.', $subjectType->describe(VerbosityLevel::typeOnly())))
0 commit comments