aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-04-22 18:11:32 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-04-30 09:23:58 +0200
commit672923f0a6ab5a692273326250fe1394b4e41bd9 (patch)
tree83f972fa6d854199a5be687531e99688dbb2ab2e /lib
parentce2d6cd81ec5aa66e9cf5040c211e1239b4bc830 (diff)
downloadnextcloud-server-672923f0a6ab5a692273326250fe1394b4e41bd9.tar.gz
nextcloud-server-672923f0a6ab5a692273326250fe1394b4e41bd9.zip
fix: Fix newly spotted psalm issues, add exhaustive typed magic properties for LDAP classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/AppFramework/Http/Request.php12
-rw-r--r--lib/private/AppFramework/Utility/SimpleContainer.php4
-rw-r--r--lib/private/Files/Storage/Local.php1
-rw-r--r--lib/private/Group/Manager.php25
-rw-r--r--lib/private/Preview/MimeIconProvider.php2
-rw-r--r--lib/private/User/Manager.php29
6 files changed, 27 insertions, 46 deletions
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php
index 7a614878ab5..af3993df8bd 100644
--- a/lib/private/AppFramework/Http/Request.php
+++ b/lib/private/AppFramework/Http/Request.php
@@ -57,12 +57,12 @@ use Symfony\Component\HttpFoundation\IpUtils;
* Class for accessing variables in the request.
* This class provides an immutable object with request variables.
*
- * @property mixed[] cookies
- * @property mixed[] env
- * @property mixed[] files
- * @property string method
- * @property mixed[] parameters
- * @property mixed[] server
+ * @property mixed[] $cookies
+ * @property mixed[] $env
+ * @property mixed[] $files
+ * @property string $method
+ * @property mixed[] $parameters
+ * @property mixed[] $server
* @template-implements \ArrayAccess<string,mixed>
*/
class Request implements \ArrayAccess, \Countable, IRequest {
diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php
index 77f09df307d..d148ecbdfc4 100644
--- a/lib/private/AppFramework/Utility/SimpleContainer.php
+++ b/lib/private/AppFramework/Utility/SimpleContainer.php
@@ -228,8 +228,8 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer {
/**
* @deprecated 20.0.0 use \OCP\IContainer::registerService
*/
- public function offsetSet($id, $service): void {
- $this->container->offsetSet($id, $service);
+ public function offsetSet($offset, $value): void {
+ $this->container->offsetSet($offset, $value);
}
/**
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 2c90a28fe3b..0861b9e8a98 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -524,6 +524,7 @@ class Local extends \OC\Files\Storage\Common {
$realPath = realpath($pathToResolve);
while ($realPath === false) { // for non existing files check the parent directory
$currentPath = dirname($currentPath);
+ /** @psalm-suppress TypeDoesNotContainType Let's be extra cautious and still check for empty string */
if ($currentPath === '' || $currentPath === '.') {
return $fullPath;
}
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php
index 2b6eb70502b..30f55107a96 100644
--- a/lib/private/Group/Manager.php
+++ b/lib/private/Group/Manager.php
@@ -98,26 +98,15 @@ class Manager extends PublicEmitter implements IGroupManager {
$this->logger = $logger;
$this->displayNameCache = new DisplayNameCache($cacheFactory, $this);
- $cachedGroups = &$this->cachedGroups;
- $cachedUserGroups = &$this->cachedUserGroups;
- $this->listen('\OC\Group', 'postDelete', function ($group) use (&$cachedGroups, &$cachedUserGroups) {
- /**
- * @var \OC\Group\Group $group
- */
- unset($cachedGroups[$group->getGID()]);
- $cachedUserGroups = [];
+ $this->listen('\OC\Group', 'postDelete', function (IGroup $group): void {
+ unset($this->cachedGroups[$group->getGID()]);
+ $this->cachedUserGroups = [];
});
- $this->listen('\OC\Group', 'postAddUser', function ($group) use (&$cachedUserGroups) {
- /**
- * @var \OC\Group\Group $group
- */
- $cachedUserGroups = [];
+ $this->listen('\OC\Group', 'postAddUser', function (IGroup $group): void {
+ $this->cachedUserGroups = [];
});
- $this->listen('\OC\Group', 'postRemoveUser', function ($group) use (&$cachedUserGroups) {
- /**
- * @var \OC\Group\Group $group
- */
- $cachedUserGroups = [];
+ $this->listen('\OC\Group', 'postRemoveUser', function (IGroup $group): void {
+ $this->cachedUserGroups = [];
});
}
diff --git a/lib/private/Preview/MimeIconProvider.php b/lib/private/Preview/MimeIconProvider.php
index 80073c307c9..d0c484d20a5 100644
--- a/lib/private/Preview/MimeIconProvider.php
+++ b/lib/private/Preview/MimeIconProvider.php
@@ -47,7 +47,7 @@ class MimeIconProvider implements IMimeIconProvider {
$aliases = $this->mimetypeDetector->getAllAliases();
// Remove comments
- $aliases = array_filter($aliases, static function ($key) {
+ $aliases = array_filter($aliases, static function (string $key) {
return !($key === '' || $key[0] === '_');
}, ARRAY_FILTER_USE_KEY);
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 66a9529483e..a8664dd2048 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -79,35 +79,26 @@ class Manager extends PublicEmitter implements IUserManager {
/**
* @var \OCP\UserInterface[] $backends
*/
- private $backends = [];
+ private array $backends = [];
/**
- * @var \OC\User\User[] $cachedUsers
+ * @var array<string,\OC\User\User> $cachedUsers
*/
- private $cachedUsers = [];
+ private array $cachedUsers = [];
- /** @var IConfig */
- private $config;
-
- /** @var ICache */
- private $cache;
-
- /** @var IEventDispatcher */
- private $eventDispatcher;
+ private ICache $cache;
private DisplayNameCache $displayNameCache;
- public function __construct(IConfig $config,
+ public function __construct(
+ private IConfig $config,
ICacheFactory $cacheFactory,
- IEventDispatcher $eventDispatcher) {
- $this->config = $config;
+ private IEventDispatcher $eventDispatcher,
+ ) {
$this->cache = new WithLocalCache($cacheFactory->createDistributed('user_backend_map'));
- $cachedUsers = &$this->cachedUsers;
- $this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) {
- /** @var \OC\User\User $user */
- unset($cachedUsers[$user->getUID()]);
+ $this->listen('\OC\User', 'postDelete', function (IUser $user): void {
+ unset($this->cachedUsers[$user->getUID()]);
});
- $this->eventDispatcher = $eventDispatcher;
$this->displayNameCache = new DisplayNameCache($cacheFactory, $this);
}