Skip to content

Commit

Permalink
fix psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jan 27, 2023
1 parent 9e1914c commit 3c5e09f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
use OCP\Share\IShare;
use OCP\Util;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;

class CloudFederationProviderFiles implements ICloudFederationProvider {

Expand Down Expand Up @@ -842,8 +843,11 @@ private function getUserDisplayName(string $userId): string {

try {
$slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
} catch (ContainerExceptionInterface $e) {
\OC::$server->getLogger()->logException($e);
} catch (\Throwable $e) {
Server::get(LoggerInterface::class)->error(
$e->getMessage(),
['exception' => $e]
);
return '';
}

Expand Down
16 changes: 11 additions & 5 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
use OCP\Share\IManager;
use OCP\Share\IShare;
use OCP\UserStatus\IManager as IUserStatusManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;

/**
* Class Share20OCS
Expand Down Expand Up @@ -372,7 +374,9 @@ private function fixMissingDisplayName(array $shares, ?array $updatedDisplayName
$userIds = $updated = [];
foreach ($shares as $share) {
// share is federated and share have no display name yet
if ($share['share_type'] === IShare::TYPE_REMOTE && $share['share_with_displayname'] === '') {
if ($share['share_type'] === IShare::TYPE_REMOTE
&& ($share['share_with'] ?? '') !== ''
&& ($share['share_with_displayname'] ?? '') === '') {
$userIds[] = $userId = $share['share_with'];

if ($updatedDisplayName !== null && array_key_exists($userId, $updatedDisplayName)) {
Expand Down Expand Up @@ -410,8 +414,7 @@ private function fixMissingDisplayName(array $shares, ?array $updatedDisplayName
* @param bool $cacheOnly - do not reach LUS, get data from cache.
*
* @return array
* @psalm-suppress DeprecatedMethod
* @psalm-suppress UndefinedClass
* @throws ContainerExceptionInterface
*/
private function retrieveFederatedDisplayName(array $userIds, bool $cacheOnly = false): array {
// check if gss is enabled and available
Expand All @@ -423,8 +426,11 @@ private function retrieveFederatedDisplayName(array $userIds, bool $cacheOnly =

try {
$slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
} catch (Exception $e) {
\OC::$server->getLogger()->logException($e);
} catch (\Throwable $e) {
Server::get(LoggerInterface::class)->error(
$e->getMessage(),
['exception' => $e]
);
return [];
}

Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<errorLevel type="suppress">
<referencedClass name="OCA\GroupFolders\Mount\GroupFolderStorage"/>
<referencedClass name="OCA\TwoFactorNextcloudNotification\Controller\APIController"/>
<referencedClass name="OCA\GlobalSiteSelector\Service\SlaveService"/>
</errorLevel>
</UndefinedClass>
<UndefinedFunction>
Expand Down Expand Up @@ -126,6 +127,7 @@
<!-- Helper classes for sharing API integration from other apps -->
<referencedClass name="OCA\Deck\Sharing\ShareAPIHelper" />
<referencedClass name="OCA\Talk\Share\Helper\DeletedShareAPIController" />
<referencedClass name="OCA\GlobalSiteSelector\Service\SlaveService"/>
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
Expand Down

0 comments on commit 3c5e09f

Please sign in to comment.