Skip to content

Commit ecd87db

Browse files
[ErrorHandler] ignore @return when there is an @template
1 parent 932f20d commit ecd87db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

DebugClassLoader.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,12 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
371371

372372
$parent = get_parent_class($class) ?: null;
373373
self::$returnTypes[$class] = [];
374+
$classIsTemplate = false;
374375

375376
// Detect annotations on the class
376377
if ($doc = $this->parsePhpDoc($refl)) {
378+
$classIsTemplate = isset($doc['template']);
379+
377380
foreach (['final', 'deprecated', 'internal'] as $annotation) {
378381
if (null !== $description = $doc[$annotation][0] ?? null) {
379382
self::${$annotation}[$class] = '' !== $description ? ' '.$description.(preg_match('/[.!]$/', $description) ? '' : '.') : '.';
@@ -517,6 +520,10 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
517520
// To read method annotations
518521
$doc = $this->parsePhpDoc($method);
519522

523+
if (($classIsTemplate || isset($doc['template'])) && $method->hasReturnType()) {
524+
unset($doc['return']);
525+
}
526+
520527
if (isset(self::$annotatedParameters[$class][$method->name])) {
521528
$definedParameters = [];
522529
foreach ($method->getParameters() as $parameter) {

0 commit comments

Comments
 (0)