Skip to content

Commit 3dabe86

Browse files
committed
refactor: corrected some linting errors
1 parent 5c19d99 commit 3dabe86

9 files changed

Lines changed: 27 additions & 33 deletions

File tree

phpmyfaq/src/phpMyFAQ/Auth/AuthHttp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function checkCredentials(string $login, #[SensitiveParameter] $password,
8989
}
9090

9191
return (
92-
$this->request->server->get('PHP_AUTH_USER') === $login
93-
&& $this->request->server->get('PHP_AUTH_PW') === $password
92+
hash_equals($login, (string) $this->request->server->get('PHP_AUTH_USER'))
93+
&& hash_equals($password, (string) $this->request->server->get('PHP_AUTH_PW'))
9494
);
9595
}
9696

phpmyfaq/src/phpMyFAQ/Auth/AuthLdap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public function create(string $login, #[SensitiveParameter] string $password, st
100100

101101
// Set user information from LDAP
102102
$user->setUserData([
103-
'display_name' => $this->ldapCore->getCompleteName($login) ?: '',
104-
'email' => $this->ldapCore->getMail($login) ?: '',
103+
'display_name' => $this->ldapCore->getCompleteName($login) ?? '',
104+
'email' => $this->ldapCore->getMail($login) ?? '',
105105
]);
106106

107107
// Handle group assignments if enabled

phpmyfaq/src/phpMyFAQ/Cache/CacheSettingsResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function resolve(): CacheSettings
7575

7676
private function normalizeRedisPrefix(string $redisPrefix): string
7777
{
78-
$normalizedPrefix = preg_replace('/[^-+_.A-Za-z0-9]/', '_', $redisPrefix) ?? '';
78+
$normalizedPrefix = preg_replace('/[^-+_.A-Za-z0-9]/', '_', subject: $redisPrefix) ?? '';
7979

80-
return trim($normalizedPrefix, '_') !== '' ? $normalizedPrefix : self::DEFAULT_REDIS_PREFIX;
80+
return trim($normalizedPrefix, characters: '_') !== '' ? $normalizedPrefix : self::DEFAULT_REDIS_PREFIX;
8181
}
8282
}

phpmyfaq/src/phpMyFAQ/Configuration/Storage/DatabaseConfigurationStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function fetchValues(array $names): array
150150
$result = $this->databaseDriver->query($query);
151151
$rows = $this->databaseDriver->fetchAll($result);
152152

153-
$values = array_fill_keys($trimmedNames, null);
153+
$values = array_fill_keys($trimmedNames, value: null);
154154
if (!is_array($rows)) {
155155
return $values;
156156
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use phpMyFAQ\Setup\EnvironmentConfigurator;
3030
use phpMyFAQ\Setup\Update;
3131
use phpMyFAQ\Setup\Upgrade;
32-
use phpMyFAQ\System;
3332
use phpMyFAQ\Translation;
3433
use Symfony\Component\HttpClient\HttpClient;
3534
use Symfony\Component\HttpFoundation\JsonResponse;

phpmyfaq/src/phpMyFAQ/Controller/Frontend/Api/TranslationController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ final class TranslationController extends AbstractController
3434
{
3535
/**
3636
* @param ?Closure(string): void $setCurrentLanguage
37-
* @param ?Closure(): array<mixed> $getTranslations
37+
* @param ?Closure(): array $getTranslations
38+
* @throws \Exception
3839
*/
3940
public function __construct(
4041
private readonly ?Closure $setCurrentLanguage = null,
@@ -57,7 +58,7 @@ public function translations(Request $request): JsonResponse
5758
Translation::getInstance()->setCurrentLanguage($language);
5859
})($language);
5960

60-
return $this->json(($this->getTranslations ?? static fn(): array => Translation::getAll())());
61+
return $this->json(($this->getTranslations ?? Translation::getAll(...))());
6162
} catch (Exception $exception) {
6263
return $this->json(['error' => $exception->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR);
6364
}

phpmyfaq/src/phpMyFAQ/Controller/Frontend/Api/UnauthorizedUserController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ public function updatePassword(Request $request): JsonResponse
7474
$email = trim((string) Filter::filterEmail($data->email));
7575

7676
if ($username !== '' && $username !== '0' && ($email !== '' && $email !== '0')) {
77-
$user = ($this->currentUserFactory
78-
?? static fn(Configuration $configuration): CurrentUser => CurrentUser::getCurrentUser(
79-
$configuration,
80-
))($this->configuration);
77+
$user = ($this->currentUserFactory ?? CurrentUser::getCurrentUser(...))($this->configuration);
8178
$loginExist = $user->getUserByLogin($username);
8279

8380
if ($loginExist && $email === $user->getUserData('email')) {

phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,21 @@ private function decodeAllEntities(string $content): string
231231
// Decode decimal entities (&#106; → j)
232232
$decoded = preg_replace_callback(
233233
'/&#(\d+);/',
234-
static fn(array $matches): string => mb_chr((int) $matches[1], 'UTF-8'),
234+
static fn(array $matches): string => mb_chr((int) $matches[1], encoding: 'UTF-8'),
235235
$decoded,
236236
);
237237
// Decode hex entities (&#x6A; → j)
238238
$decoded = preg_replace_callback(
239239
'/&#x([0-9a-fA-F]+);/',
240-
static fn(array $matches): string => mb_chr(hexdec($matches[1]), 'UTF-8'),
240+
static fn(array $matches): string => mb_chr(hexdec($matches[1]), encoding: 'UTF-8'),
241241
$decoded,
242242
);
243243
// Decode named HTML entities (&amp; → &, &lt; → <, etc.)
244-
$decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, 'UTF-8');
244+
$decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, encoding: 'UTF-8');
245245
}
246246

247247
// Strip null bytes and control characters that could break regex matching
248-
return preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/', '', $decoded);
248+
return preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/', replacement: '', subject: $decoded);
249249
}
250250

251251
/**

phpmyfaq/src/phpMyFAQ/Service/McpServer/McpSdkRuntime.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,28 @@
1919

2020
namespace phpMyFAQ\Service\McpServer;
2121

22+
use Mcp\Server;
23+
use Mcp\Server\Transport\StdioTransport;
2224
use phpMyFAQ\Configuration;
2325
use RuntimeException;
2426
use Symfony\Component\Console\Input\InputInterface;
2527
use Symfony\Component\Console\Output\OutputInterface;
2628

27-
final class McpSdkRuntime implements McpServerRuntimeInterface
29+
final readonly class McpSdkRuntime implements McpServerRuntimeInterface
2830
{
2931
/**
3032
* @param array<string, mixed> $serverInfo
3133
*/
3234
public function __construct(
33-
private readonly Configuration $configuration,
34-
private readonly FaqSearchTool $faqSearchTool,
35-
private readonly array $serverInfo,
35+
private Configuration $configuration,
36+
private FaqSearchTool $faqSearchTool,
37+
private array $serverInfo,
3638
) {
3739
}
3840

3941
public function runConsole(InputInterface $input, OutputInterface $output): void
4042
{
41-
$this->buildServer()->run(new \Mcp\Server\Transport\StdioTransport());
43+
$this->buildServer()->run(new StdioTransport());
4244
}
4345

4446
public function getServerInfo(): array
@@ -67,34 +69,29 @@ public function faqSearch(
6769
'all_languages' => $all_languages,
6870
]);
6971

70-
$decoded = json_decode($result['content'], true);
72+
$decoded = json_decode($result['content'], associative: true);
7173

7274
return json_last_error() === JSON_ERROR_NONE ? $decoded : $result['content'];
7375
}
7476

75-
private function buildServer(): \Mcp\Server
77+
private function buildServer(): Server
7678
{
77-
if (!class_exists(\Mcp\Server::class) || !class_exists(\Mcp\Server\Transport\StdioTransport::class)) {
79+
if (!class_exists(Server::class) || !class_exists(StdioTransport::class)) {
7880
throw new RuntimeException(
7981
'The mcp/sdk package is not installed or does not expose the expected server classes.',
8082
);
8183
}
8284

8385
$definition = $this->faqSearchTool->getDefinition();
8486

85-
return \Mcp\Server::builder()
87+
return Server::builder()
8688
->setServerInfo(
8789
(string) $this->serverInfo['name'],
8890
(string) $this->serverInfo['version'],
8991
(string) ($this->serverInfo['description'] ?? null),
9092
)
9193
->addTool(
92-
fn(
93-
string $query,
94-
?int $category_id = null,
95-
int $limit = 10,
96-
bool $all_languages = false,
97-
): array|string => $this->faqSearch($query, $category_id, $limit, $all_languages),
94+
$this->faqSearch(...),
9895
$definition->name,
9996
$definition->description,
10097
null,

0 commit comments

Comments
 (0)