Skip to content

Commit 53ea7f2

Browse files
committed
fix: corrected type errors
1 parent 96873b6 commit 53ea7f2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

phpmyfaq/src/phpMyFAQ/Administration/Report.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,12 @@ public function convertEncoding(string $outputString = ''): string
150150

151151
/**
152152
* Sanitizes input to avoid CSV injection.
153-
* @param string|int $value
153+
* @param int|string $value
154+
* @return string|int
154155
*/
155-
public static function sanitize($value): string
156+
public static function sanitize(int|string $value): string|int
156157
{
157-
if (preg_match('/[=\+\-\@\|]/', $value)) {
158+
if (preg_match('/[=\+\-\@\|]/', (string) $value)) {
158159
return '"' . str_replace('"', '""', $value) . '"';
159160
}
160161

phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/StatisticsController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* The Statistics Controller
75
*
@@ -17,6 +15,8 @@
1715
* @since 2024-04-21
1816
*/
1917

18+
declare(strict_types=1);
19+
2020
namespace phpMyFAQ\Controller\Administration\Api;
2121

2222
use JsonException;
@@ -78,7 +78,8 @@ public function truncateSessions(Request $request): JsonResponse
7878
return $this->json(['error' => Translation::get(key: 'msgNoPermission')], Response::HTTP_UNAUTHORIZED);
7979
}
8080

81-
$month = Filter::filterVar($request->attributes->get('month'), FILTER_SANITIZE_SPECIAL_CHARS);
81+
$month = Filter::filterVar($request->getPayload()->get('month'), FILTER_SANITIZE_SPECIAL_CHARS);
82+
8283
if ($this->container->get(id: 'phpmyfaq.helper.statistics')->deleteTrackingFiles($month)) {
8384
return $this->json(['success' => Translation::get(key: 'ad_adminlog_delete_success')], Response::HTTP_OK);
8485
}

phpmyfaq/src/phpMyFAQ/Helper/StatisticsHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public function deleteTrackingFiles(string $month): bool
171171
$dir = opendir(PMF_ROOT_DIR . '/content/core/data');
172172
$first = PHP_INT_MAX;
173173
$last = 0;
174+
174175
while ($trackingFile = readdir($dir)) {
175176
// The filename format is: trackingDDMMYYYY
176177
// e.g.: tracking02042006

0 commit comments

Comments
 (0)