diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-07-28 07:50:17 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-10-14 10:45:16 +0200 |
commit | cea2f79bbd02ba9eafa9993baa513ce8900d9f3f (patch) | |
tree | d0773ba1390941c0d4c82d41c64ce74e9805236e /lib | |
parent | f49ccd140fd5ada0aa640f6642464ad149c980e6 (diff) | |
download | nextcloud-server-cea2f79bbd02ba9eafa9993baa513ce8900d9f3f.tar.gz nextcloud-server-cea2f79bbd02ba9eafa9993baa513ce8900d9f3f.zip |
Improve container return type annotations
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/Utility/SimpleContainer.php | 9 | ||||
-rw-r--r-- | lib/private/Server.php | 5 | ||||
-rw-r--r-- | lib/private/ServerContainer.php | 7 | ||||
-rw-r--r-- | lib/public/Server.php | 8 |
4 files changed, 24 insertions, 5 deletions
diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 429382aa223..da1efdec826 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -53,6 +53,15 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { $this->container = new Container(); } + /** + * @template T + * @param class-string<T>|string $id + * @return T|mixed + * @psalm-template S as class-string<T>|string + * @psalm-param S $id + * @psalm-return (S is class-string<T> ? T : mixed) + * @throws QueryException + */ public function get(string $id) { return $this->query($id); } diff --git a/lib/private/Server.php b/lib/private/Server.php index a94e0d568b0..33ac8262cea 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -155,6 +155,7 @@ use OC\Template\JSCombiner; use OC\User\DisplayNameCache; use OC\User\Listeners\BeforeUserDeletedListener; use OC\User\Listeners\UserChangedListener; +use OC\User\Session; use OCA\Theming\ImageManager; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; @@ -1672,7 +1673,7 @@ class Server extends ServerContainer implements IServerContainer { * @deprecated 20.0.0 */ public function getSession() { - return $this->get(IUserSession::class)->getSession(); + return $this->get(Session::class)->getSession(); } /** @@ -1680,7 +1681,7 @@ class Server extends ServerContainer implements IServerContainer { */ public function setSession(\OCP\ISession $session) { $this->get(SessionStorage::class)->setSession($session); - $this->get(IUserSession::class)->setSession($session); + $this->get(Session::class)->setSession($session); $this->get(Store::class)->setSession($session); } diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index d6bec7526b7..0bc99f6c152 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -127,6 +127,13 @@ class ServerContainer extends SimpleContainer { } /** + * @template T + * @param class-string<T>|string $name + * @return T|mixed + * @psalm-template S as class-string<T>|string + * @psalm-param S $name + * @psalm-return (S is class-string<T> ? T : mixed) + * @throws QueryException * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get */ public function query(string $name, bool $autoload = true) { diff --git a/lib/public/Server.php b/lib/public/Server.php index f4522e8ae10..92560e2b17e 100644 --- a/lib/public/Server.php +++ b/lib/public/Server.php @@ -41,9 +41,11 @@ use Psr\Container\NotFoundExceptionInterface; final class Server { /** * @template T - * @template S as class-string<T>|string - * @param S $serviceName - * @return (S is class-string<T> ? T : mixed) + * @param class-string<T>|string $serviceName + * @return T|mixed + * @psalm-template S as class-string<T>|string + * @psalm-param S $serviceName + * @psalm-return (S is class-string<T> ? T : mixed) * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @since 25.0.0 |