From 311cbbc4933ef282ca8478a0e36174ede4e152ac Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 10 Jul 2020 00:22:09 +0200 Subject: [PATCH] Annotate how query works https://github.com/phan/phan/wiki/Generic-Types#indicating-a-method-creates-an-instance-of-the-passed-in-class-name Signed-off-by: Daniel Kesselberg --- lib/private/AppFramework/Utility/SimpleContainer.php | 6 ++++++ lib/public/IContainer.php | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 3bb275a4d3c13..4e8b5e37b5e62 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -52,6 +52,12 @@ public function __construct() { $this->container = new Container(); } + /** + * @template T + * @param class-string $id + * @return T + * @throws QueryException + */ public function get($id) { return $this->query($id); } diff --git a/lib/public/IContainer.php b/lib/public/IContainer.php index 74fdf4aba5b52..9cedbcccd1679 100644 --- a/lib/public/IContainer.php +++ b/lib/public/IContainer.php @@ -66,9 +66,10 @@ public function resolve($name); /** * Look up a service for a given name in the container. * - * @param string $name + * @template T + * @param class-string $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 + * @return T * @throws ContainerExceptionInterface if the query could not be resolved * @throws QueryException if the query could not be resolved * @since 6.0.0