Skip to content

Commit e600c54

Browse files
Merge branch '5.4' into 6.0
* 5.4: bug #45043 [ErrorHandler] ignore ``@return`` when there is an ``@template`` (nicolas-grekas) [Finder] fix tests on Windows
2 parents a6040e7 + 060bc01 commit e600c54

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)