Skip to content

Commit f9f20b6

Browse files
ChristophWurstMorrisJobke
authored andcommitted
Annotate IContainer so Psalm knows what resove and query return
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent a41b273 commit f9f20b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/public/IContainer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@
5252
interface IContainer extends ContainerInterface {
5353

5454
/**
55+
* @template T
56+
*
5557
* If a parameter is not registered in the container try to instantiate it
5658
* by using reflection to find out how to build the class
5759
* @param string $name the class name to resolve
60+
* @psalm-param string|class-string<T> $name
5861
* @return \stdClass
62+
* @psalm-return ($name is class-string ? T : mixed)
5963
* @since 8.2.0
6064
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
6165
* @throws ContainerExceptionInterface if the class could not be found or instantiated
@@ -66,9 +70,13 @@ public function resolve($name);
6670
/**
6771
* Look up a service for a given name in the container.
6872
*
73+
* @template T
74+
*
6975
* @param string $name
76+
* @psalm-param string|class-string<T> $name
7077
* @param bool $autoload Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example
7178
* @return mixed
79+
* @psalm-return ($name is class-string ? T : mixed)
7280
* @throws ContainerExceptionInterface if the query could not be resolved
7381
* @throws QueryException if the query could not be resolved
7482
* @since 6.0.0

0 commit comments

Comments
 (0)