Skip to content

Commit 2aa9cd0

Browse files
authored
Merge pull request #7451 from LibreSign/backport/7450/stable32
[stable32] chore(rector): apply safe test-only batch and php81 baseline
2 parents af62ddd + 98a9124 commit 2aa9cd0

30 files changed

+52
-71
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './3rdparty/*' -not -path './vendor-bin/*' -not -path './node_modules/*' -not -path './build/*' -not -path './tests/integration/vendor/*' -print0 | xargs -0 -n1 php -l",
2323
"cs:check": "php-cs-fixer fix --dry-run --diff",
2424
"cs:fix": "php-cs-fixer fix",
25+
"rector:check": "rector --dry-run",
26+
"rector:fix": "rector",
2527
"openapi": "generate-spec --verbose && (npm run typescript:generate || echo 'Please manually regenerate the typescript OpenAPI models')",
2628
"psalm": "psalm --no-cache --threads=$(nproc)",
2729
"psalm:update-baseline": "psalm --threads=$(nproc) --update-baseline --set-baseline=tests/psalm-baseline.xml",

lib/Controller/CrlApiController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function revoke(
152152
'success' => false,
153153
'message' => $e->getMessage(),
154154
], Http::STATUS_BAD_REQUEST);
155-
} catch (\Exception $e) {
155+
} catch (\Exception) {
156156
return new DataResponse([
157157
'success' => false,
158158
'message' => 'An error occurred while revoking the certificate',

lib/Controller/FileController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ public function addFileToEnvelope(string $uuid): DataResponse {
607607
$response = $this->fileListService->formatFileWithChildren($envelope, $addedFiles, $this->userSession->getUser());
608608
return new DataResponse($response, Http::STATUS_OK);
609609

610-
} catch (DoesNotExistException $e) {
610+
} catch (DoesNotExistException) {
611611
return new DataResponse(
612612
['message' => $this->l10n->t('Envelope not found')],
613613
Http::STATUS_NOT_FOUND,
@@ -713,14 +713,14 @@ private function processUploadedFiles(array $uploadedFiles): array {
713713
$this->fileService->validateUploadedFile($uploadedFile);
714714
$filesArray[] = [
715715
'uploadedFile' => $uploadedFile,
716-
'name' => pathinfo($uploadedFile['name'], PATHINFO_FILENAME),
716+
'name' => pathinfo((string)$uploadedFile['name'], PATHINFO_FILENAME),
717717
];
718718
}
719719
} else {
720720
$this->fileService->validateUploadedFile($uploadedFiles);
721721
$filesArray[] = [
722722
'uploadedFile' => $uploadedFiles,
723-
'name' => pathinfo($uploadedFiles['name'], PATHINFO_FILENAME),
723+
'name' => pathinfo((string)$uploadedFiles['name'], PATHINFO_FILENAME),
724724
];
725725
}
726726
}
@@ -756,7 +756,7 @@ private function extractFileName(array $fileData): string {
756756
return $fileData['name'];
757757
}
758758
if (!empty($fileData['url'])) {
759-
return rawurldecode(pathinfo($fileData['url'], PATHINFO_FILENAME));
759+
return rawurldecode(pathinfo((string)$fileData['url'], PATHINFO_FILENAME));
760760
}
761761
return '';
762762
}

lib/Controller/PageController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function indexFPath(string $path): TemplateResponse {
251251
$this->initialState->provideInitialState('identificationDocumentsWaitingApproval', $file['settings']['identificationDocumentsWaitingApproval'] ?? false);
252252
} catch (LibresignException $e) {
253253
throw $e;
254-
} catch (\Throwable $e) {
254+
} catch (\Throwable) {
255255
throw new LibresignException(json_encode([
256256
'action' => JSActions::ACTION_DO_NOTHING,
257257
'errors' => [['message' => $this->l10n->t('Invalid UUID')]],

lib/Db/CrlMapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ public function getRevokedCertificates(string $instanceId = '', int $generation
154154
}
155155

156156
public function isInvalidAt(string $serialNumber, ?DateTime $checkDate = null): bool {
157-
$checkDate = $checkDate ?? new DateTime();
157+
$checkDate ??= new DateTime();
158158

159159
try {
160160
$certificate = $this->findBySerialNumber($serialNumber);
161-
} catch (DoesNotExistException $e) {
161+
} catch (DoesNotExistException) {
162162
return false;
163163
}
164164

@@ -174,7 +174,7 @@ public function isInvalidAt(string $serialNumber, ?DateTime $checkDate = null):
174174
}
175175

176176
public function cleanupExpiredCertificates(?DateTime $before = null): int {
177-
$before = $before ?? new DateTime('-1 year');
177+
$before ??= new DateTime('-1 year');
178178

179179
$qb = $this->db->getQueryBuilder();
180180

lib/Db/SignRequestMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public function getFilesToSearchProvider(IUser $user, string $fileName, int $lim
503503
$file = File::fromRow($row);
504504

505505
$files[] = $file;
506-
} catch (\Exception $e) {
506+
} catch (\Exception) {
507507
continue;
508508
}
509509
}

lib/Handler/SignEngine/Pkcs12Handler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private function extractTimestampData(array $decoded, array $result): array {
170170
if (!empty($timestampData['genTime']) || !empty($timestampData['policy']) || !empty($timestampData['serialNumber'])) {
171171
$result['timestamp'] = $timestampData;
172172
}
173-
} catch (\Throwable $e) {
173+
} catch (\Throwable) {
174174
}
175175

176176
if (!isset($result['signingTime']) || !$result['signingTime'] instanceof \DateTime) {
@@ -247,7 +247,7 @@ private function hasLibreSignCaId(array $parsed): bool {
247247
}
248248

249249
foreach ($organizationalUnits as $ou) {
250-
$ou = trim($ou);
250+
$ou = trim((string)$ou);
251251
if ($this->caIdentifierService->isValidCaId($ou, $instanceId)) {
252252
return true;
253253
}

lib/Listener/BeforeNodeDeletedListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function markOriginalFileAsDeleted(int $fileId, ?string $metadataJson =
129129
if (is_array($decoded)) {
130130
$existingMetadata = $decoded;
131131
}
132-
} catch (\Throwable $e) {
132+
} catch (\Throwable) {
133133
}
134134
}
135135

lib/Listener/MailNotifyListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private function isNotificationDisabledAtActivity(string $userId, string $type):
180180
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
181181
try {
182182
$manager->getSettingById($type);
183-
} catch (\Exception $e) {
183+
} catch (\Exception) {
184184
return false;
185185
}
186186

lib/Listener/NotificationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private function isNotificationDisabledAtActivity(string $userId, string $type):
213213
$manager = \OCP\Server::get(\OCP\Activity\IManager::class);
214214
try {
215215
$manager->getSettingById($type);
216-
} catch (\Exception $e) {
216+
} catch (\Exception) {
217217
return false;
218218
}
219219

0 commit comments

Comments
 (0)