From 25564e4244103d342bf9bbda86204d4b919f848b Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Thu, 26 Mar 2026 21:57:21 +0100 Subject: [PATCH] Fix all PHPStan errors: add missing iterable types and fix CacheInterface::clear() - Add @param array to AnalyticsController::createVisitor() - Add @param/@return array to AnalyticsCryptoService encrypt/decrypt - Add @param array|null to InfraService calcCpuPercent/calcMemory - Merge duplicate docblocks on InfraService::calcMemory() - Use intersection type CacheInterface&CacheItemPoolInterface for MeilisearchService cache Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Controller/AnalyticsController.php | 1 + src/Service/AnalyticsCryptoService.php | 2 ++ src/Service/InfraService.php | 3 +++ src/Service/MeilisearchService.php | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Controller/AnalyticsController.php b/src/Controller/AnalyticsController.php index a51ac58..be139b2 100644 --- a/src/Controller/AnalyticsController.php +++ b/src/Controller/AnalyticsController.php @@ -79,6 +79,7 @@ class AnalyticsController extends AbstractController return new Response('', 204); } + /** @param array $data */ private function createVisitor( Request $request, array $data, diff --git a/src/Service/AnalyticsCryptoService.php b/src/Service/AnalyticsCryptoService.php index 9fee7d3..eb714b3 100644 --- a/src/Service/AnalyticsCryptoService.php +++ b/src/Service/AnalyticsCryptoService.php @@ -14,6 +14,7 @@ class AnalyticsCryptoService $this->key = substr(hash('sha256', $this->analyticsSecret, true), 0, 32); } + /** @param array $data */ public function encrypt(array $data): string { $json = json_encode($data, \JSON_THROW_ON_ERROR); @@ -24,6 +25,7 @@ class AnalyticsCryptoService return base64_encode($iv.$encrypted.$tag); } + /** @return array|null */ public function decrypt(string $payload): ?array { $raw = base64_decode($payload, true); diff --git a/src/Service/InfraService.php b/src/Service/InfraService.php index 1caf3bb..8c9556c 100644 --- a/src/Service/InfraService.php +++ b/src/Service/InfraService.php @@ -224,6 +224,7 @@ class InfraService return $result; } + /** @param array|null $stats */ private function calcCpuPercent(?array $stats): string { if (!$stats) { @@ -241,6 +242,8 @@ class InfraService } /** + * @param array|null $stats + * * @return array{used: string, limit: string, percent: string} */ private function calcMemory(?array $stats): array diff --git a/src/Service/MeilisearchService.php b/src/Service/MeilisearchService.php index e1a614f..55aaceb 100644 --- a/src/Service/MeilisearchService.php +++ b/src/Service/MeilisearchService.php @@ -3,6 +3,7 @@ namespace App\Service; use App\Message\MeilisearchMessage; +use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Contracts\Cache\CacheInterface; @@ -16,7 +17,7 @@ class MeilisearchService private MessageBusInterface $bus, #[Autowire(env: 'MEILISEARCH_URL')] private string $url, #[Autowire(env: 'MEILISEARCH_API_KEY')] private string $apiKey, - #[Autowire(service: 'meilisearch.cache')] private CacheInterface $cache, + #[Autowire(service: 'meilisearch.cache')] private CacheInterface&CacheItemPoolInterface $cache, ) { }