Merge pull request #23446 from nextcloud/backport/23377/stable20

[stable20] Annotate IContainer so Psalm knows what resove and query return
This commit is contained in:
Morris Jobke 2020-10-14 17:40:06 +02:00 committed by GitHub
commit 5e9e90655e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -52,10 +52,14 @@ use Psr\Container\ContainerInterface;
interface IContainer extends ContainerInterface { interface IContainer extends ContainerInterface {
/** /**
* @template T
*
* If a parameter is not registered in the container try to instantiate it * If a parameter is not registered in the container try to instantiate it
* by using reflection to find out how to build the class * by using reflection to find out how to build the class
* @param string $name the class name to resolve * @param string $name the class name to resolve
* @psalm-param string|class-string<T> $name
* @return \stdClass * @return \stdClass
* @psalm-return ($name is class-string ? T : mixed)
* @since 8.2.0 * @since 8.2.0
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
* @throws ContainerExceptionInterface if the class could not be found or instantiated * @throws ContainerExceptionInterface if the class could not be found or instantiated
@ -66,9 +70,13 @@ interface IContainer extends ContainerInterface {
/** /**
* Look up a service for a given name in the container. * Look up a service for a given name in the container.
* *
* @template T
*
* @param string $name * @param string $name
* @psalm-param string|class-string<T> $name
* @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 * @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
* @return mixed * @return mixed
* @psalm-return ($name is class-string ? T : mixed)
* @throws ContainerExceptionInterface if the query could not be resolved * @throws ContainerExceptionInterface if the query could not be resolved
* @throws QueryException if the query could not be resolved * @throws QueryException if the query could not be resolved
* @since 6.0.0 * @since 6.0.0