Skip to content

Commit 2471df3

Browse files
minor symfony#61723 [HttpKernel] Refine ControllerEvent::getAttributes() and ControllerArgumentsEvent::getAttributes() return types (7-zete-7)
This PR was merged into the 7.4 branch. Discussion ---------- [HttpKernel] Refine `ControllerEvent::getAttributes()` and `ControllerArgumentsEvent::getAttributes()` return types | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix symfony#61722 | License | MIT The return type for the `Symfony\Component\HttpKernel\Event\ControllerEvent::getAttributes()` method is refined so that when the `$className` argument is passed, the return type matches the passed list of objects of the passed class. Commits ------- 533abf4 [HttpKernel] Refine ControllerEvent::getAttributes() and ControllerArgumentsEvent::getAttributes() return types
2 parents c287443 + 533abf4 commit 2471df3

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,11 @@ public function getNamedArguments(): array
9797
}
9898

9999
/**
100-
* @template T of class-string|null
100+
* @template T of object
101101
*
102-
* @param T $className
102+
* @param class-string<T>|null $className
103103
*
104-
* @return array<class-string, list<object>>|list<object>
105-
*
106-
* @psalm-return (T is null ? array<class-string, list<object>> : list<object>)
104+
* @return ($className is null ? array<class-string, list<object>> : list<T>)
107105
*/
108106
public function getAttributes(?string $className = null): array
109107
{

src/Symfony/Component/HttpKernel/Event/ControllerEvent.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,11 @@ public function setController(callable $controller, ?array $attributes = null):
7979
}
8080

8181
/**
82-
* @template T of class-string|null
82+
* @template T of object
8383
*
84-
* @param T $className
84+
* @param class-string<T>|null $className
8585
*
86-
* @return array<class-string, list<object>>|list<object>
87-
*
88-
* @psalm-return (T is null ? array<class-string, list<object>> : list<object>)
86+
* @return ($className is null ? array<class-string, list<object>> : list<T>)
8987
*/
9088
public function getAttributes(?string $className = null): array
9189
{

0 commit comments

Comments
 (0)