Skip to content

Commit 0ac2a90

Browse files
authored
Merge pull request #33388 from nextcloud/enh/container-annotations
2 parents a8101ec + cea2f79 commit 0ac2a90

5 files changed

Lines changed: 28 additions & 6 deletions

File tree

build/psalm-baseline.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@
840840
</RedundantCondition>
841841
<TypeDoesNotContainType occurrences="2">
842842
<code>get_class($res) === 'OpenSSLAsymmetricKey'</code>
843+
<code>is_object($res)</code>
843844
</TypeDoesNotContainType>
844845
</file>
845846
<file src="apps/encryption/lib/Crypto/EncryptAll.php">
@@ -3159,7 +3160,6 @@
31593160
<code>bool</code>
31603161
<code>int</code>
31613162
<code>string</code>
3162-
<code>string</code>
31633163
</InvalidReturnType>
31643164
<InvalidScalarArgument occurrences="5">
31653165
<code>$lastChunkPos</code>
@@ -3619,6 +3619,9 @@
36193619
<code>\OCP\Calendar\Room\IManager</code>
36203620
<code>\OCP\Files\Folder|null</code>
36213621
</ImplementedReturnTypeMismatch>
3622+
<InvalidArgument occurrences="1">
3623+
<code>new GenericEvent($user)</code>
3624+
</InvalidArgument>
36223625
<InvalidCatch occurrences="1"/>
36233626
<UndefinedDocblockClass occurrences="1">
36243627
<code>\OC\OCSClient</code>

lib/private/AppFramework/Utility/SimpleContainer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ public function __construct() {
5353
$this->container = new Container();
5454
}
5555

56+
/**
57+
* @template T
58+
* @param class-string<T>|string $id
59+
* @return T|mixed
60+
* @psalm-template S as class-string<T>|string
61+
* @psalm-param S $id
62+
* @psalm-return (S is class-string<T> ? T : mixed)
63+
* @throws QueryException
64+
*/
5665
public function get(string $id) {
5766
return $this->query($id);
5867
}

lib/private/Server.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
use OC\User\DisplayNameCache;
156156
use OC\User\Listeners\BeforeUserDeletedListener;
157157
use OC\User\Listeners\UserChangedListener;
158+
use OC\User\Session;
158159
use OCA\Theming\ImageManager;
159160
use OCA\Theming\ThemingDefaults;
160161
use OCA\Theming\Util;
@@ -1672,15 +1673,15 @@ public function getUserSession() {
16721673
* @deprecated 20.0.0
16731674
*/
16741675
public function getSession() {
1675-
return $this->get(IUserSession::class)->getSession();
1676+
return $this->get(Session::class)->getSession();
16761677
}
16771678

16781679
/**
16791680
* @param \OCP\ISession $session
16801681
*/
16811682
public function setSession(\OCP\ISession $session) {
16821683
$this->get(SessionStorage::class)->setSession($session);
1683-
$this->get(IUserSession::class)->setSession($session);
1684+
$this->get(Session::class)->setSession($session);
16841685
$this->get(Store::class)->setSession($session);
16851686
}
16861687

lib/private/ServerContainer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ public function has($id, bool $noRecursion = false): bool {
127127
}
128128

129129
/**
130+
* @template T
131+
* @param class-string<T>|string $name
132+
* @return T|mixed
133+
* @psalm-template S as class-string<T>|string
134+
* @psalm-param S $name
135+
* @psalm-return (S is class-string<T> ? T : mixed)
136+
* @throws QueryException
130137
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
131138
*/
132139
public function query(string $name, bool $autoload = true) {

lib/public/Server.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141
final class Server {
4242
/**
4343
* @template T
44-
* @template S as class-string<T>|string
45-
* @param S $serviceName
46-
* @return (S is class-string<T> ? T : mixed)
44+
* @param class-string<T>|string $serviceName
45+
* @return T|mixed
46+
* @psalm-template S as class-string<T>|string
47+
* @psalm-param S $serviceName
48+
* @psalm-return (S is class-string<T> ? T : mixed)
4749
* @throws ContainerExceptionInterface
4850
* @throws NotFoundExceptionInterface
4951
* @since 25.0.0

0 commit comments

Comments
 (0)