From bd7817a801b113474696d0c23704f583b81c4ffc Mon Sep 17 00:00:00 2001 From: Giovanni Martins Date: Thu, 23 Nov 2023 20:01:49 -0300 Subject: [PATCH] remove unused imports and typing some declaration Signed-off-by: Giovanni Martins --- lib/Command/Configure/Cfssl.php | 2 +- lib/Command/Configure/OpenSsl.php | 2 +- lib/Controller/FileController.php | 2 +- lib/Db/AccountFileMapper.php | 2 +- lib/Helper/ValidateHelper.php | 4 ++-- lib/Middleware/InjectionMiddleware.php | 8 +++----- lib/Service/FileService.php | 2 +- tests/Unit/Handler/Pkcs12HandlerTest.php | 5 ++--- tests/Unit/Service/SignFileServiceTest.php | 3 +-- tests/integration/features/bootstrap/FeatureContext.php | 2 +- 10 files changed, 14 insertions(+), 18 deletions(-) diff --git a/lib/Command/Configure/Cfssl.php b/lib/Command/Configure/Cfssl.php index 82ed9e57ed..4a94352eaf 100644 --- a/lib/Command/Configure/Cfssl.php +++ b/lib/Command/Configure/Cfssl.php @@ -85,7 +85,7 @@ protected function configure(): void { ); } - protected function execute(InputInterface $input, OutputInterface $output): int { + protected function execute(InputInterface $input): int { if (!$this->installService->isCfsslBinInstalled()) { throw new InvalidArgumentException('CFSSL binary not found! run libresign:istall --cfssl first.'); } diff --git a/lib/Command/Configure/OpenSsl.php b/lib/Command/Configure/OpenSsl.php index f0844be7be..c8fdf45ece 100644 --- a/lib/Command/Configure/OpenSsl.php +++ b/lib/Command/Configure/OpenSsl.php @@ -79,7 +79,7 @@ protected function configure(): void { ); } - protected function execute(InputInterface $input, OutputInterface $output): int { + protected function execute(InputInterface $input): int { $names = []; if (!$commonName = $input->getOption('cn')) { throw new InvalidArgumentException('Invalid Comon Name'); diff --git a/lib/Controller/FileController.php b/lib/Controller/FileController.php index db676220ae..280385bd2a 100644 --- a/lib/Controller/FileController.php +++ b/lib/Controller/FileController.php @@ -138,7 +138,7 @@ public function list($page = null, $length = null): JSONResponse { #[NoCSRFRequired] public function getPage(string $uuid, int $page) { try { - $page = $this->fileService->getPage($uuid, $page, $this->userSession->getUser()->getUID()); + $page = $this->fileService->getPage($uuid, $page); return new DataDisplayResponse( $page, Http::STATUS_OK, diff --git a/lib/Db/AccountFileMapper.php b/lib/Db/AccountFileMapper.php index bda16af854..4b6e991705 100644 --- a/lib/Db/AccountFileMapper.php +++ b/lib/Db/AccountFileMapper.php @@ -113,7 +113,7 @@ public function accountFileList(array $filter, int $page = null, int $length = n return $return; } - private function getUserAccountFile(array $filter = [], bool $count = false): Pagination { + private function getUserAccountFile(array $filter = []): Pagination { $qb = $this->db->getQueryBuilder(); $qb->select( 'f.id', diff --git a/lib/Helper/ValidateHelper.php b/lib/Helper/ValidateHelper.php index dcf481e875..4d2e6b3897 100644 --- a/lib/Helper/ValidateHelper.php +++ b/lib/Helper/ValidateHelper.php @@ -287,10 +287,10 @@ public function validateVisibleElementsRelation(array $list, SignRequest $signRe throw new LibresignException($this->l10n->t('Field %s does not belong to user', $elements['profileElementId'])); } } - $this->validateUserHasNecessaryElements($signRequest, $user, $list); + $this->validateUserHasNecessaryElements($signRequest, $list); } - private function validateUserHasNecessaryElements(SignRequest $signRequest, IUser $user, array $list = []): void { + private function validateUserHasNecessaryElements(SignRequest $signRequest, array $list = []): void { $fileElements = $this->fileElementMapper->getByFileIdAndSignRequestId($signRequest->getFileId(), $signRequest->getId()); $total = array_filter($fileElements, function (FileElement $fileElement) use ($list, $signRequest): bool { $found = array_filter($list, function ($item) use ($fileElement): bool { diff --git a/lib/Middleware/InjectionMiddleware.php b/lib/Middleware/InjectionMiddleware.php index 04a2c252d9..db1b299b4e 100644 --- a/lib/Middleware/InjectionMiddleware.php +++ b/lib/Middleware/InjectionMiddleware.php @@ -127,13 +127,11 @@ private function requireSigner(): void { } /** - * @param Controller $controller - * @param string $methodName - * @param \Exception $exception - * @throws \Exception + * @param \Exception $exception * @return Response + *@throws \Exception */ - public function afterException($controller, $methodName, \Exception $exception): Response { + public function afterException(\Exception $exception): Response { switch (true) { case $exception instanceof LibresignException: if ($this->isJson($exception->getMessage())) { diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index ade2025dfe..3259b2f7bc 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -425,7 +425,7 @@ public function formatFile(): array { return $return; } - public function getPage(string $uuid, int $page, string $uid): string { + public function getPage(string $uuid, int $page): string { $libreSignFile = $this->fileMapper->getByUuid($uuid); $uid = $this->userSession->getUser()->getUID(); if ($libreSignFile->getUserId() !== $uid) { diff --git a/tests/Unit/Handler/Pkcs12HandlerTest.php b/tests/Unit/Handler/Pkcs12HandlerTest.php index 36440af189..eb7cf902a1 100644 --- a/tests/Unit/Handler/Pkcs12HandlerTest.php +++ b/tests/Unit/Handler/Pkcs12HandlerTest.php @@ -21,8 +21,7 @@ final class Pkcs12HandlerTest extends \OCA\Libresign\Tests\Unit\TestCase { private CfsslHandler|MockObject $cfsslHandler; private IL10N|MockObject $l10n; private JSignPdfHandler|MockObject $jSignPdfHandler; - private OpenSslHandler|MockObject $openSslHandler; - private CertificateEngineHandler|MockObject $certificateEngineHandler; + private CertificateEngineHandler|MockObject $certificateEngineHandler; private array $cfsslHandlerBuffer = []; public function setUp(): void { @@ -112,7 +111,7 @@ public function testGetFooterWithSuccess() { $this->config = $this->createMock(IConfig::class); $this->config ->method('getAppValue') - ->willReturnCallback(function ($appid, $key, $default) { + ->willReturnCallback(function ($key) { switch ($key) { case 'add_footer': return 1; case 'validation_site': return 'http://test.coop'; diff --git a/tests/Unit/Service/SignFileServiceTest.php b/tests/Unit/Service/SignFileServiceTest.php index b1c28ebff6..5ea5473283 100644 --- a/tests/Unit/Service/SignFileServiceTest.php +++ b/tests/Unit/Service/SignFileServiceTest.php @@ -51,8 +51,7 @@ final class SignFileServiceTest extends \OCA\Libresign\Tests\Unit\TestCase { private IEventDispatcher|MockObject $eventDispatcher; private IURLGenerator|MockObject $urlGenerator; private SignMethodService|MockObject $signMethod; - private IdentifyMethodService|MockObject $identifyMethod; - private IdentifyMethodMapper|MockObject $identifyMethodMapper; + private IdentifyMethodMapper|MockObject $identifyMethodMapper; private ITempManager|MockObject $tempManager; public function setUp(): void { diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index f9b0d888a8..716b4b2c86 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -19,7 +19,7 @@ class FeatureContext extends NextcloudApiContext implements OpenedEmailStorageAw /** * @BeforeSuite */ - public static function beforeSuite(BeforeSuiteScope $scope) { + public static function beforeSuite() { exec('php ../../../../occ config:system:set debug --value true --type boolean'); }