]> source.dussan.org Git - nextcloud-server.git/commitdiff
Annotate IContainer so Psalm knows what resove and query return
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Mon, 12 Oct 2020 11:15:40 +0000 (13:15 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 14 Oct 2020 10:29:26 +0000 (12:29 +0200)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/public/IContainer.php

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