Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unused symbols #1971

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/Command/Configure/Cfssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use OCA\Libresign\Command\Base;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Cfssl extends Base {
protected function configure(): void {
Expand Down Expand Up @@ -85,7 +84,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.');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Command/Configure/OpenSsl.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use OCA\Libresign\Command\Base;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class OpenSsl extends Base {
protected function configure(): void {
Expand Down Expand Up @@ -79,7 +78,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');
Expand Down
21 changes: 14 additions & 7 deletions lib/Command/Developer/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ private function resetNotifications(string $user): void {
$delete->andWhere($delete->expr()->eq('user', $delete->createNamedParameter($user)));
}
$delete->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand All @@ -158,7 +159,8 @@ private function resetIdentifyMethods(): void {
$delete = $this->db->getQueryBuilder();
$delete->delete('libresign_identify_method')
->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand All @@ -167,7 +169,8 @@ private function resetSignRequest(): void {
$delete = $this->db->getQueryBuilder();
$delete->delete('libresign_sign_request')
->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand All @@ -176,7 +179,8 @@ private function resetFile(): void {
$delete = $this->db->getQueryBuilder();
$delete->delete('libresign_file')
->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand All @@ -185,7 +189,8 @@ private function resetFileElement(): void {
$delete = $this->db->getQueryBuilder();
$delete->delete('libresign_file_element')
->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand All @@ -194,7 +199,8 @@ private function resetUserElement(): void {
$delete = $this->db->getQueryBuilder();
$delete->delete('libresign_user_element')
->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand All @@ -205,7 +211,8 @@ private function resetConfig(): void {
->where($delete->expr()->eq('appid', $delete->createNamedParameter(Application::APP_ID)))
->andWhere($delete->expr()->notIn('configkey', $delete->createNamedParameter(['enabled', 'installed_version'], IQueryBuilder::PARAM_STR_ARRAY)))
->executeStatement();
} catch (\Throwable $e) {
} catch (\Throwable) {
// TODO: Add the exception
}
}
}
2 changes: 1 addition & 1 deletion lib/Controller/AEnvironmentPageAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function loadSignRequestUuid(string $uuid): void {
$this->fileEntity = $this->signFileService->getFile(
$this->signRequestEntity->getFileId(),
);
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
throw new LibresignException(json_encode([
'action' => JSActions::ACTION_DO_NOTHING,
'errors' => [$this->l10n->t('Invalid UUID')],
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function getSignatureElements(): JSONResponse {
],
Http::STATUS_OK
);
} catch (\Throwable $th) {
} catch (\Throwable) {
return new JSONResponse(
[
'message' => $this->l10n->t('Elements not found')
Expand All @@ -293,7 +293,7 @@ public function getSignatureElement($elementId): JSONResponse {
$this->accountService->getUserElementByElementId($userId, $elementId),
Http::STATUS_OK
);
} catch (\Throwable $th) {
} catch (\Throwable) {
return new JSONResponse(
[
'message' => $this->l10n->t('Element not found')
Expand Down Expand Up @@ -338,7 +338,7 @@ public function deleteSignatureElement($elementId): JSONResponse {
$userId = $this->userSession->getUser()->getUID();
try {
$this->accountService->deleteSignatureElement($userId, $elementId);
} catch (\Throwable $th) {
} catch (\Throwable) {
return new JSONResponse(
[
'message' => $this->l10n->t('Element not found')
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function index(): TemplateResponse {
try {
$this->validateHelper->canRequestSign($this->userSession->getUser());
$this->initialState->provideInitialState('can_request_sign', true);
} catch (LibresignException $th) {
} catch (LibresignException) {
$this->initialState->provideInitialState('can_request_sign', false);
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public function signAccountFile($uuid): TemplateResponse {
try {
$fileEntity = $this->signFileService->getFileByUuid($uuid);
$this->signFileService->getAccountFileById($fileEntity->getId());
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
$config = [
'action' => JSActions::ACTION_DO_NOTHING,
'errors' => [$this->l10n->t('Invalid UUID')],
Expand Down Expand Up @@ -190,7 +190,7 @@ public function getPdf($uuid) {
$this->throwIfValidationPageNotAccessible();
try {
$file = $this->accountService->getPdfByUuid($uuid);
} catch (DoesNotExistException $th) {
} catch (DoesNotExistException) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}

Expand Down Expand Up @@ -321,7 +321,7 @@ public function validationFile(string $uuid): TemplateResponse {
try {
$fileEntity = $this->signFileService->getFileByUuid($uuid);
$this->signFileService->getAccountFileById($fileEntity->getId());
} catch (DoesNotExistException $e) {
} catch (DoesNotExistException) {
$config = [
'action' => JSActions::ACTION_DO_NOTHING,
'errors' => [$this->l10n->t('Invalid UUID')],
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/SignFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ private function getCode(string $uuid = null, int $fileId = null): JSONResponse
} else {
$signRequest = $this->signRequestMapper->getByUuidAndUserId($uuid, $user->getUID());
}
} catch (\Throwable $th) {
} catch (\Throwable) {
throw new LibresignException($this->l10n->t('Invalid data to sign file'), 1);
}
$this->validateHelper->canRequestCode($signRequest);
$libreSignFile = $this->fileMapper->getById($signRequest->getFileId());
$this->validateHelper->fileCanBeSigned($libreSignFile);
$this->signFileService->requestCode($signRequest, $user);
$message = $this->l10n->t('The code to sign file was successfully requested.');
} catch (SmsTransmissionException $e) {
} catch (SmsTransmissionException) {
// There was an error when to send SMS code to user.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can remove this comment @vitormattos

$message = $this->l10n->t('Failed to send code.');
$statusCode = Http::STATUS_UNPROCESSABLE_ENTITY;
Expand Down
4 changes: 1 addition & 3 deletions lib/Db/AccountFileMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -236,7 +236,6 @@ private function formatListRow(array $row, string $url): array {
*/
private function assocFileToSignRequestAndFormat(array $files, array $signers): array {
foreach ($files as $key => $file) {
$totalSigned = 0;
$files[$key]['file']['signers'] = [];
foreach ($signers as $signerKey => $signer) {
if ($signer->getFileId() === $file['id']) {
Expand All @@ -256,7 +255,6 @@ private function assocFileToSignRequestAndFormat(array $files, array $signers):
$data['sign_date'] = (new \DateTime())
->setTimestamp($signer->getSigned())
->format('Y-m-d H:i:s');
$totalSigned++;
}
$files[$key]['file']['signers'][] = $data;
unset($signers[$signerKey]);
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/UserElementMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function findOne(array $data): UserElement {
$qb = $this->getQueryBuilder($data);
try {
$row = $this->findOneQuery($qb);
} catch (\Throwable $th) {
} catch (\Throwable) {
$qb->andWhere(
$qb->expr()->eq('ue.starred', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
);
Expand Down
2 changes: 1 addition & 1 deletion lib/Files/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function handle(Event $event): void {
try {
$this->validateHelper->canRequestSign($this->userSession->getUser());
$this->initialState->provideInitialState('can_request_sign', true);
} catch (LibresignException $th) {
} catch (LibresignException) {
$this->initialState->provideInitialState('can_request_sign', false);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Handler/CertificateEngine/AEngineHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function generateCertificate(string $certificate, string $privateKey): st
if (!$certContent) {
throw new \Exception();
}
} catch (\Throwable $th) {
} catch (\Throwable) {
throw new LibresignException('Error while creating certificate file', 500);
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public function getConfigPath(): string {
if (!$folder->fileExists('/')) {
throw new \Exception();
}
} catch (\Throwable $th) {
} catch (\Throwable) {
$folder = $this->appData->newFolder($this->getName() . '_config');
}
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
Expand Down
6 changes: 4 additions & 2 deletions lib/Handler/CertificateEngine/CfsslHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ private function portOpen(): bool {
$port = parse_url($this->getCfsslUri(), PHP_URL_PORT);
try {
$socket = fsockopen($host, $port, $errno, $errstr, 0.1);
} catch (\Throwable $th) {
} catch (\Throwable) {
// TODO: Add the exception
}
if (isset($socket) && is_resource($socket)) {
fclose($socket);
Expand Down Expand Up @@ -283,7 +284,8 @@ public function isSetupOk(): bool {
try {
$this->getClient();
return true;
} catch (\Throwable $th) {
} catch (\Throwable) {
// TODO: Add the exception
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Handler/CertificateEngine/OpenSslHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function generateRootCert(
}

$csr = openssl_csr_new($dn, $privkey, array('digest_alg' => 'sha256'));
$x509 = openssl_csr_sign($csr, null, $privkey, $days = 365 * 5, array('digest_alg' => 'sha256'));
$x509 = openssl_csr_sign($csr, null, $privkey, 365 * 5, array('digest_alg' => 'sha256'));

openssl_csr_export($csr, $csrout);
openssl_x509_export($x509, $certout);
Expand Down
3 changes: 2 additions & 1 deletion lib/Handler/Pkcs12Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function deletePfx(string $uid): void {
try {
$file = $folder->get($this->pfxFilename);
$file->delete();
} catch (\Throwable $th) {
} catch (\Throwable) {
// TODO: Add the exception
}
}

Expand Down
Loading
Loading