Skip to content

Commit

Permalink
fix a few psalm errors
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc committed Jan 5, 2023
1 parent 843ddee commit 34893d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
10 changes: 1 addition & 9 deletions core/Controller/ReferenceApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@

namespace OC\Core\Controller;

use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\Collaboration\Reference\IDiscoverableReferenceProvider;
use OCP\Collaboration\Reference\IReferenceManager;
use OCP\IRequest;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class ReferenceApiController extends \OCP\AppFramework\OCSController {
private IReferenceManager $referenceManager;
Expand Down Expand Up @@ -99,12 +96,7 @@ public function resolve(array $references, int $limit = 1): DataResponse {
* @return DataResponse
*/
public function getProvidersInfo(): DataResponse {
try {
$providers = $this->referenceManager->getDiscoverableProviders();
} catch (ContainerExceptionInterface | NotFoundExceptionInterface $e) {
return new DataResponse(['message' => 'Error getting providers'], Http::STATUS_NOT_FOUND);
}

$providers = $this->referenceManager->getDiscoverableProviders();
$jsonProviders = array_map(static function (IDiscoverableReferenceProvider $provider) {
return $provider->jsonSerialize();
}, $providers);
Expand Down
14 changes: 1 addition & 13 deletions lib/private/Collaboration/Reference/ReferenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Throwable;

Expand All @@ -63,7 +61,7 @@ public function __construct(LinkReferenceProvider $linkReferenceProvider, ICache
* Extract a list of URLs from a text
*
* @param string $text
* @return array|string[]
* @return string[]
*/
public function extractReferences(string $text): array {
preg_match_all(IURLGenerator::URL_REGEX, $text, $matches);
Expand All @@ -78,8 +76,6 @@ public function extractReferences(string $text): array {
*
* @param string $referenceId
* @return IReference|null
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getReferenceFromCache(string $referenceId): ?IReference {
$matchedProvider = $this->getMatchedProvider($referenceId);
Expand Down Expand Up @@ -113,8 +109,6 @@ public function getReferenceByCacheKey(string $cacheKey): ?IReference {
*
* @param string $referenceId
* @return IReference|null
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function resolveReference(string $referenceId): ?IReference {
$matchedProvider = $this->getMatchedProvider($referenceId);
Expand Down Expand Up @@ -144,8 +138,6 @@ public function resolveReference(string $referenceId): ?IReference {
*
* @param string $referenceId
* @return IReferenceProvider|null the first matching provider
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function getMatchedProvider(string $referenceId): ?IReferenceProvider {
$matchedProvider = null;
Expand Down Expand Up @@ -195,8 +187,6 @@ public function invalidateCache(string $cachePrefix, ?string $cacheKey = null):

/**
* @return IReferenceProvider[]
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getProviders(): array {
if ($this->providers === null) {
Expand Down Expand Up @@ -230,8 +220,6 @@ public function getProviders(): array {
* If the provider is searchable, also get the list of supported unified search providers
*
* @return IDiscoverableReferenceProvider[]
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getDiscoverableProviders(): array {
// preserve 0 based index to avoid returning an object in data responses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\IInitialStateService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class RenderReferenceEventListener implements IEventListener {
private IReferenceManager $manager;
Expand All @@ -55,12 +53,7 @@ public function handle(Event $event): void {
return;
}

try {
$providers = $this->manager->getDiscoverableProviders();
} catch (ContainerExceptionInterface | NotFoundExceptionInterface $e) {
return;
}

$providers = $this->manager->getDiscoverableProviders();
$jsonProviders = array_map(static function (IDiscoverableReferenceProvider $provider) {
return $provider->jsonSerialize();
}, $providers);
Expand Down

0 comments on commit 34893d7

Please sign in to comment.