From 85cca34c8fbd6b642bca039d6a02e8ecd5f153ed Mon Sep 17 00:00:00 2001 From: exaby73 Date: Thu, 12 Sep 2024 06:15:16 +0530 Subject: [PATCH] chore: CS and Psalm fixes --- src/Collector/Neo4jDataCollector.php | 9 ++++++--- src/Event/PostRunEvent.php | 6 +++--- src/EventListener/Neo4jProfileListener.php | 21 +++++++++++++++++---- src/SymfonyClient.php | 4 ++-- tests/App/Controller/TestController.php | 3 +-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/Collector/Neo4jDataCollector.php b/src/Collector/Neo4jDataCollector.php index 5457264..9edebff 100644 --- a/src/Collector/Neo4jDataCollector.php +++ b/src/Collector/Neo4jDataCollector.php @@ -32,12 +32,15 @@ public function collect(Request $request, Response $response, ?\Throwable $excep $profiledSummaries = $this->subscriber->getProfiledSummaries(); $successfulStatements = array_map( static function (string $key, mixed $value) { - if ('result' !== $key) { - return [...$value, 'status' => 'success']; + if ('result' !== $key && /* Is always array */ is_array($value)) { + return [ + ...$value, + 'status' => 'success', + ]; } return array_map( - static function (string $key, mixed $obj) { + static function (mixed $obj) { if (is_object($obj) && method_exists($obj, 'toArray')) { return $obj->toArray(); } diff --git a/src/Event/PostRunEvent.php b/src/Event/PostRunEvent.php index 05a0afb..0c7a43c 100644 --- a/src/Event/PostRunEvent.php +++ b/src/Event/PostRunEvent.php @@ -12,9 +12,9 @@ class PostRunEvent extends Event public const EVENT_ID = 'neo4j.post_run'; public function __construct( - private ?string $alias, - private ResultSummary $result, - private \DateTimeInterface $time + private readonly ?string $alias, + private readonly ResultSummary $result, + private readonly \DateTimeInterface $time ) { } diff --git a/src/EventListener/Neo4jProfileListener.php b/src/EventListener/Neo4jProfileListener.php index ddeb023..e5c91d7 100644 --- a/src/EventListener/Neo4jProfileListener.php +++ b/src/EventListener/Neo4jProfileListener.php @@ -4,7 +4,6 @@ namespace Neo4j\Neo4jBundle\EventListener; -use DateTimeInterface; use Laudis\Neo4j\Databags\ResultSummary; use Laudis\Neo4j\Databags\Statement; use Laudis\Neo4j\Exception\Neo4jException; @@ -19,13 +18,21 @@ final class Neo4jProfileListener implements EventSubscriberInterface, ResetInter * @var list */ private array $profiledSummaries = []; /** - * @var list + * @var list */ private array $profiledFailures = []; @@ -80,7 +87,13 @@ public function getProfiledSummaries(): array } /** - * @return list + * @return list */ public function getProfiledFailures(): array { diff --git a/src/SymfonyClient.php b/src/SymfonyClient.php index 615f748..2290e36 100644 --- a/src/SymfonyClient.php +++ b/src/SymfonyClient.php @@ -25,8 +25,8 @@ class SymfonyClient implements ClientInterface * @param ClientInterface> $client */ public function __construct( - private ClientInterface $client, - private EventHandler $handler + private readonly ClientInterface $client, + private readonly EventHandler $handler ) { } diff --git a/tests/App/Controller/TestController.php b/tests/App/Controller/TestController.php index 34734ae..c9f7152 100644 --- a/tests/App/Controller/TestController.php +++ b/tests/App/Controller/TestController.php @@ -16,13 +16,12 @@ public function __construct( public function __invoke(Profiler $profiler): Response { - // dd($profiler->loadProfile('0a1909')); // Successful statement $this->client->run('MATCH (n) RETURN n'); try { // Failing statement $this->client->run('MATCH (n) {x: $x}', ['x' => 1]); - } catch (\Exception $e) { + } catch (\Exception) { // ignore }