10000 bug #45043 [ErrorHandler] ignore ``@return`` when there is an ``@temp… · symfony/symfony@326944d · GitHub
[go: up one dir, main page]

Skip to content

Commit 326944d

Browse files
bug #45043 [ErrorHandler] ignore @return when there is an @template (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [ErrorHandler] ignore ``@return`` when there is an ``@template`` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - And update .github/expected-missing-return-types.diff Commits ------- d1aa509 [ErrorHandler] ignore ``@return`` when there is an ``@template``
1 parent 1a2def3 commit 326944d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Symfony/Component/ErrorHandler/DebugClassLoader.php

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

369369
$parent = get_parent_class($class) ?: null;
370370
self::$returnTypes[$class] = [];
371+
$classIsTemplate = false;
371372

372373
// Detect annotations on the class
373374
if ($doc = $this->parsePhpDoc($refl)) {
375+
$classIsTemplate = isset($doc['template']);
376+
374377
foreach (['final', 'deprecated', 'internal'] as $annotation) {
375378
if (null !== $description = $doc[$annotation][0] ?? null) {
376379
self::${$annotation}[$class] = '' !== $description ? ' '.$description.(preg_match('/[.!]$/', $description) ? '' : '.') : '.';
@@ -514,6 +517,10 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
514517
// To read method annotations
515518
$doc = $this->parsePhpDoc($method);
516519

520+
if (($classIsTemplate || isset($doc['template'])) && $method->hasReturnType()) {
521+
unset($doc['return']);
522+
}
523+
517524
if (isset(self::$annotatedParameters[$class][$method->name])) {
518525
$definedParameters = [];
519526
foreach ($method->getParameters() as $parameter) {

0 commit comments

Comments
 (0)
0