Skip to content

Commit

Permalink
chore: CS and Psalm fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Sep 12, 2024
1 parent e24a8b7 commit 85cca34
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/Collector/Neo4jDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Event/PostRunEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}

Expand Down
21 changes: 17 additions & 4 deletions src/EventListener/Neo4jProfileListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,13 +18,21 @@ final class Neo4jProfileListener implements EventSubscriberInterface, ResetInter
* @var list<array{
* result: ResultSummary,
* alias: string|null,
* time: DateTimeInterface
* time: string,
* start_time: float|int,
* end_time: float|int
* }>
*/
private array $profiledSummaries = [];

/**
* @var list<array{exception: Neo4jException, statement: Statement, alias: string|null}>
* @var list<array{
* exception: Neo4jException,
* statement: Statement,
* alias: string|null,
* time: string,
* timestamp: int
* }>
*/
private array $profiledFailures = [];

Expand Down Expand Up @@ -80,7 +87,13 @@ public function getProfiledSummaries(): array
}

/**
* @return list<array{exception: Neo4jException, statement: Statement, alias: string|null}>
* @return list<array{
* exception: Neo4jException,
* statement: Statement,
* alias: string|null,
* time: string,
* timestamp: int
* }>
*/
public function getProfiledFailures(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/SymfonyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class SymfonyClient implements ClientInterface
* @param ClientInterface<SummarizedResult<CypherMap>> $client
*/
public function __construct(
private ClientInterface $client,
private EventHandler $handler
private readonly ClientInterface $client,
private readonly EventHandler $handler
) {
}

Expand Down
3 changes: 1 addition & 2 deletions tests/App/Controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 85cca34

Please sign in to comment.