]> source.dussan.org Git - nextcloud-server.git/commitdiff
Improve container return type annotations 33388/head
authorJulius Härtl <jus@bitgrid.net>
Thu, 28 Jul 2022 05:50:17 +0000 (07:50 +0200)
committerJulius Härtl <jus@bitgrid.net>
Fri, 14 Oct 2022 08:45:16 +0000 (10:45 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
build/psalm-baseline.xml
lib/private/AppFramework/Utility/SimpleContainer.php
lib/private/Server.php
lib/private/ServerContainer.php
lib/public/Server.php

index 8132311ff879e7ac49d5115c1e8123c185b45cea..ec96d5843793969b6f661e1a7765c6a40185ed46 100644 (file)
     </RedundantCondition>
     <TypeDoesNotContainType occurrences="2">
       <code>get_class($res) === 'OpenSSLAsymmetricKey'</code>
+      <code>is_object($res)</code>
     </TypeDoesNotContainType>
   </file>
   <file src="apps/encryption/lib/Crypto/EncryptAll.php">
       <code>bool</code>
       <code>int</code>
       <code>string</code>
-      <code>string</code>
     </InvalidReturnType>
     <InvalidScalarArgument occurrences="5">
       <code>$lastChunkPos</code>
       <code>\OCP\Calendar\Room\IManager</code>
       <code>\OCP\Files\Folder|null</code>
     </ImplementedReturnTypeMismatch>
+    <InvalidArgument occurrences="1">
+      <code>new GenericEvent($user)</code>
+    </InvalidArgument>
     <InvalidCatch occurrences="1"/>
     <UndefinedDocblockClass occurrences="1">
       <code>\OC\OCSClient</code>
index 429382aa223b292a94f9b645e78159326d8260ee..da1efdec826da5d312f3e5702071b232ce58d524 100644 (file)
@@ -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);
        }
index a94e0d568b08e6466a02d56a7d218f3c5ff8b0fa..33ac8262ceab77714664fb9693eceda34e44dcf8 100644 (file)
@@ -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);
        }
 
index d6bec7526b7312171beefd207583b8805ecc94be..0bc99f6c152a9636cd8e922cf53b35f721762375 100644 (file)
@@ -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) {
index f4522e8ae1080a895d06b1073d7f50ed05e300ad..92560e2b17e4ff86a92629dbca8c89378e93f4d5 100644 (file)
@@ -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