Skip to content

Commit

Permalink
Fix new reported psalm issues
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
  • Loading branch information
CarlSchwan committed Jan 14, 2022
1 parent 26fbd2e commit 987c53b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
7 changes: 2 additions & 5 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1639,8 +1639,7 @@
<InvalidArgument occurrences="1">
<code>$files_list</code>
</InvalidArgument>
<InvalidScalarArgument occurrences="3">
<code>$freeSpace</code>
<InvalidScalarArgument occurrences="1">
<code>$maxUploadFilesize</code>
<code>$maxUploadFilesize</code>
</InvalidScalarArgument>
Expand Down Expand Up @@ -1967,10 +1966,8 @@
</InvalidScalarArgument>
</file>
<file src="apps/sharebymail/lib/ShareByMailProvider.php">
<InvalidScalarArgument occurrences="4">
<InvalidScalarArgument occurrences="2">
<code>$share-&gt;getId()</code>
<code>$shareId</code>
<code>$shareId</code>
<code>(int)$data['id']</code>
</InvalidScalarArgument>
</file>
Expand Down
7 changes: 4 additions & 3 deletions lib/private/AppFramework/Utility/SimpleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public function __construct() {
}

/**
* @template T
* @param class-string<T> $id
* @return T
* @psalm-suppress MoreSpecificImplementedParamType
* @psalm-template T
* @psalm-param class-string<T> $id
* @psalm-return T
*/
public function get(string $id) {
return $this->query($id);
Expand Down
20 changes: 12 additions & 8 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
use OC\Preview\GeneratorHelper;
use OC\Remote\Api\ApiFactory;
use OC\Remote\InstanceFactory;
use OC\RedisFactory;
use OC\RichObjectStrings\Validator;
use OC\Route\Router;
use OC\Security\Bruteforce\Throttler;
Expand Down Expand Up @@ -163,6 +164,7 @@
use OCP\Encryption\IFile;
use OCP\Encryption\Keys\IStorage;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\GenericEvent;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
Expand Down Expand Up @@ -248,7 +250,6 @@
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use OCA\Files_External\Service\UserStoragesService;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Service\GlobalStoragesService;
Expand Down Expand Up @@ -1156,8 +1157,9 @@ public function __construct($webRoot, \OC\Config $config) {
/** @deprecated 19.0.0 */
$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);

$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
$this->registerService('ThemingDefaults', function (Server $c) {
$this->registerAlias(\OC_Defaults::class, ThemingDefaults::class);
$this->registerAlias('ThemingDefaults', ThemingDefaults::class);
$this->registerService(ThemingDefaults::class, function (Server $c) {
/*
* Dark magic for autoloader.
* If we do a class_exists it will try to load the class which will
Expand Down Expand Up @@ -1261,7 +1263,7 @@ public function __construct($webRoot, \OC\Config $config) {
$c->get(SymfonyAdapter::class),
$c->get(IMailer::class),
$c->get(IURLGenerator::class),
$c->get('ThemingDefaults'),
$c->get(ThemingDefaults::class),
$c->get(IEventDispatcher::class),
$c->get(IUserSession::class),
$c->get(KnownUserService::class)
Expand Down Expand Up @@ -1645,6 +1647,7 @@ public function getUserSession() {
* @deprecated 20.0.0
*/
public function getSession() {
/** @psalm-suppress UndefinedInterfaceMethod */
return $this->get(IUserSession::class)->getSession();
}

Expand All @@ -1653,6 +1656,7 @@ public function getSession() {
*/
public function setSession(\OCP\ISession $session) {
$this->get(SessionStorage::class)->setSession($session);
/** @psalm-suppress UndefinedInterfaceMethod */
$this->get(IUserSession::class)->setSession($session);
$this->get(Store::class)->setSession($session);
}
Expand Down Expand Up @@ -1763,7 +1767,7 @@ public function getMemCacheFactory() {
* @deprecated 20.0.0
*/
public function getGetRedisFactory() {
return $this->get('RedisFactory');
return $this->get(RedisFactory::class);
}


Expand Down Expand Up @@ -2117,11 +2121,11 @@ public function getCommentsManager() {
}

/**
* @return \OCA\Theming\ThemingDefaults
* @return ThemingDefaults
* @deprecated 20.0.0
*/
public function getThemingDefaults() {
return $this->get('ThemingDefaults');
return $this->get(ThemingDefaults::class);
}

/**
Expand Down Expand Up @@ -2243,7 +2247,7 @@ public function getAutoCompleteManager() {
* @deprecated 20.0.0
*/
public function getLDAPProvider() {
return $this->get('LDAPProvider');
return $this->get(\OCA\User_LDAP\LDAPProvider::class);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Template/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function getCoreTemplateDirs($theme, $serverRoot) {
/**
* Assign variables
* @param string $key key
* @param array|bool|integer|string|Throwable $value value
* @param mixed $value value
* @return bool
*
* This function assigns a variable. It can be accessed via $_[$key] in
Expand Down

0 comments on commit 987c53b

Please sign in to comment.