Skip to content

Commit fa4b6ca

Browse files
committed
upgrade to driver version 3.3
1 parent 1751d47 commit fa4b6ca

31 files changed

+164
-130
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.1-cli
1+
FROM php:8.4-cli
22
RUN apt-get update \
33
&& apt-get install -y \
44
libzip-dev \

composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
{
99
"name": "Ghlen Nagels",
1010
"email": "[email protected]"
11+
},
12+
{
13+
"name": "Nabeel Parkar",
14+
"email": "[email protected]"
1115
}
1216
],
1317
"require": {
1418
"php": ">=8.1",
15-
"laudis/neo4j-php-client": "^3.2",
19+
"laudis/neo4j-php-client": "^3.3",
1620
"twig/twig": "^3.0",
1721
"ext-json": "*",
1822
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
@@ -23,7 +27,7 @@
2327
"kubawerlos/php-cs-fixer-custom-fixers": "^3.0",
2428
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0",
2529
"phpunit/phpunit": "^9.5",
26-
"psalm/plugin-phpunit": "^0.18",
30+
"psalm/plugin-phpunit": "^0.19.5",
2731
"psalm/plugin-symfony": "^5.0",
2832
"symfony/console": "^5.4 || ^6.0 || ^7.0",
2933
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
@@ -35,7 +39,7 @@
3539
"symfony/uid": "^6.4",
3640
"symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0",
3741
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
38-
"vimeo/psalm": "^5.15.0"
42+
"vimeo/psalm": "^6.11"
3943
},
4044
"autoload": {
4145
"psr-4": {

docker-compose.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ services:
2424
- neo4j-symfony
2525

2626
neo4j:
27-
environment:
28-
- NEO4J_AUTH=neo4j/testtest
2927
image: neo4j:5.22
3028
ports:
3129
- ${DOCKER_HOST_NEO4J_HTTP_PORT:-7474}:7474
3230
- ${DOCKER_HOST_NEO4J_BOLT_PORT:-7687}:7687
31+
environment:
32+
- NEO4J_AUTH=neo4j/testtest
33+
34+
# advertise “neo4j:7687” instead of localhost
35+
- NEO4J_server_default__advertised__address=neo4j
36+
- NEO4J_server_bolt_advertised__address=neo4j:7687
3337
networks:
3438
- neo4j-symfony
35-

phpunit.xml.dist

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="./vendor/autoload.php"
5+
colors="true"
6+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
7+
failOnWarning="true"
8+
beStrictAboutOutputDuringTests="true"
9+
>
310
<testsuites>
411
<testsuite name="Functional tests">
512
<directory suffix="Test.php">./tests/Functional</directory>

src/Builders/ClientBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ClientBuilder
2121
/**
2222
* @psalm-mutation-free
2323
*
24-
* @param DriverSetupManager<mixed> $driverSetups
24+
* @param DriverSetupManager $driverSetups
2525
*/
2626
public function __construct(
2727
private SessionConfiguration $defaultSessionConfig,

src/Collector/Neo4jDataCollector.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
namespace Neo4j\Neo4jBundle\Collector;
66

77
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
8+
use Override;
89
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
910
use Symfony\Component\HttpFoundation\Request;
1011
use Symfony\Component\HttpFoundation\Response;
12+
use Throwable;
1113

1214
/**
1315
* @var array{
@@ -27,7 +29,8 @@ public function __construct(
2729
) {
2830
}
2931

30-
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
32+
#[Override]
33+
public function collect(Request $request, Response $response, ?Throwable $exception = null): void
3134
{
3235
$t = $this;
3336
$profiledSummaries = $this->subscriber->getProfiledSummaries();
@@ -75,12 +78,14 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
7578
$this->data['statements'] = $mergedArray;
7679
}
7780

81+
#[Override]
7882
public function reset(): void
7983
{
8084
parent::reset();
8185
$this->subscriber->reset();
8286
}
8387

88+
#[Override]
8489
public function getName(): string
8590
{
8691
return 'neo4j';
@@ -125,12 +130,13 @@ public function getQueryCount(): int
125130
return count($this->data['statements']);
126131
}
127132

133+
#[Override]
128134
public static function getTemplate(): ?string
129135
{
130136
return '@Neo4j/web_profiler.html.twig';
131137
}
132138

133-
private function recursiveToArray(mixed $obj): mixed
139+
private function recursiveToArray(array|object $obj): mixed
134140
{
135141
if (is_array($obj)) {
136142
return array_map(
@@ -139,7 +145,7 @@ private function recursiveToArray(mixed $obj): mixed
139145
);
140146
}
141147

142-
if (is_object($obj) && method_exists($obj, 'toArray')) {
148+
if (method_exists($obj, 'toArray')) {
143149
return $obj->toArray();
144150
}
145151

src/Decorators/SymfonyClient.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,9 @@
1717
use Laudis\Neo4j\Types\CypherList;
1818
use Laudis\Neo4j\Types\CypherMap;
1919
use Neo4j\Neo4jBundle\Factories\SymfonyDriverFactory;
20+
use Override;
2021

21-
/**
22-
* A collection of drivers with methods to run queries though them.
23-
*
24-
* @implements ClientInterface<SummarizedResult<CypherMap>>
25-
*
26-
* @psalm-external-mutation-free
27-
*
28-
* @psalm-suppress ImpureMethodCall
29-
*/
30-
class SymfonyClient implements ClientInterface
22+
final class SymfonyClient implements ClientInterface
3123
{
3224
/**
3325
* @var array<string, list<SymfonyTransaction>>
@@ -42,7 +34,7 @@ class SymfonyClient implements ClientInterface
4234
/**
4335
* @psalm-mutation-free
4436
*
45-
* @param DriverSetupManager<mixed> $driverSetups
37+
* @param DriverSetupManager $driverSetups
4638
*/
4739
public function __construct(
4840
private readonly DriverSetupManager $driverSetups,
@@ -62,11 +54,13 @@ public function getDefaultTransactionConfiguration(): TransactionConfiguration
6254
return $this->defaultTransactionConfiguration;
6355
}
6456

57+
#[Override]
6558
public function run(string $statement, iterable $parameters = [], ?string $alias = null): SummarizedResult
6659
{
6760
return $this->runStatement(Statement::create($statement, $parameters), $alias);
6861
}
6962

63+
#[Override]
7064
public function runStatement(Statement $statement, ?string $alias = null): SummarizedResult
7165
{
7266
return $this->runStatements([$statement], $alias)->first();
@@ -97,6 +91,7 @@ private function getSession(?string $alias = null): SymfonySession
9791
return $this->boundSessions[$alias] = $this->startSession($alias, $this->defaultSessionConfiguration);
9892
}
9993

94+
#[Override]
10095
public function runStatements(iterable $statements, ?string $alias = null): CypherList
10196
{
10297
$runner = $this->getRunner($alias);
@@ -107,6 +102,7 @@ public function runStatements(iterable $statements, ?string $alias = null): Cyph
107102
return $runner->runStatements($statements);
108103
}
109104

105+
#[Override]
110106
public function beginTransaction(?iterable $statements = null, ?string $alias = null, ?TransactionConfiguration $config = null): SymfonyTransaction
111107
{
112108
$session = $this->getSession($alias);
@@ -115,6 +111,7 @@ public function beginTransaction(?iterable $statements = null, ?string $alias =
115111
return $session->beginTransaction($statements, $config);
116112
}
117113

114+
#[Override]
118115
public function getDriver(?string $alias): SymfonyDriver
119116
{
120117
return $this->factory->createDriver(
@@ -141,6 +138,7 @@ private function startSession(?string $alias, SessionConfiguration $configuratio
141138
*
142139
* @return HandlerResult
143140
*/
141+
#[Override]
144142
public function writeTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null): mixed
145143
{
146144
if ($this->defaultSessionConfiguration->getAccessMode() === AccessMode::WRITE()) {
@@ -160,6 +158,7 @@ public function writeTransaction(callable $tsxHandler, ?string $alias = null, ?T
160158
*
161159
* @return HandlerResult
162160
*/
161+
#[Override]
163162
public function readTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null): mixed
164163
{
165164
if ($this->defaultSessionConfiguration->getAccessMode() === AccessMode::READ()) {
@@ -179,21 +178,25 @@ public function readTransaction(callable $tsxHandler, ?string $alias = null, ?Tr
179178
*
180179
* @return HandlerResult
181180
*/
181+
#[Override]
182182
public function transaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null)
183183
{
184184
return $this->writeTransaction($tsxHandler, $alias, $config);
185185
}
186186

187+
#[Override]
187188
public function verifyConnectivity(?string $driver = null): bool
188189
{
189190
return $this->driverSetups->verifyConnectivity($this->defaultSessionConfiguration, $driver);
190191
}
191192

193+
#[Override]
192194
public function hasDriver(string $alias): bool
193195
{
194196
return $this->driverSetups->hasDriver($alias);
195197
}
196198

199+
#[Override]
197200
public function bindTransaction(?string $alias = null, ?TransactionConfiguration $config = null): void
198201
{
199202
$alias ??= $this->driverSetups->getDefaultAlias();
@@ -202,6 +205,7 @@ public function bindTransaction(?string $alias = null, ?TransactionConfiguration
202205
$this->boundTransactions[$alias][] = $this->beginTransaction(null, $alias, $config);
203206
}
204207

208+
#[Override]
205209
public function rollbackBoundTransaction(?string $alias = null, int $depth = 1): void
206210
{
207211
$this->popTransactions(static fn (SymfonyTransaction $tsx) => $tsx->rollback(), $alias, $depth);
@@ -227,6 +231,7 @@ private function popTransactions(callable $handler, ?string $alias = null, int $
227231
}
228232
}
229233

234+
#[Override]
230235
public function commitBoundTransaction(?string $alias = null, int $depth = 1): void
231236
{
232237
$this->popTransactions(static fn (UnmanagedTransactionInterface $tsx) => $tsx->commit(), $alias, $depth);

src/Decorators/SymfonyDriver.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
use Laudis\Neo4j\Basic\Driver;
66
use Laudis\Neo4j\Contracts\DriverInterface;
77
use Laudis\Neo4j\Databags\SessionConfiguration;
8-
use Laudis\Neo4j\Databags\SummarizedResult;
9-
use Laudis\Neo4j\Types\CypherMap;
108
use Neo4j\Neo4jBundle\Factories\SymfonyDriverFactory;
9+
use Override;
1110

1211
/**
13-
* @implements DriverInterface<SummarizedResult<CypherMap>>
14-
*
15-
* @psalm-immutable
16-
*
17-
* @psalm-suppress ImpureMethodCall
12+
* @psalm-suppress MissingImmutableAnnotation
1813
*/
19-
class SymfonyDriver implements DriverInterface
14+
final class SymfonyDriver implements DriverInterface
2015
{
2116
public function __construct(
2217
private readonly Driver $driver,
@@ -26,16 +21,19 @@ public function __construct(
2621
) {
2722
}
2823

24+
#[Override]
2925
public function createSession(?SessionConfiguration $config = null): SymfonySession
3026
{
3127
return $this->factory->createSession($this->driver, $config, $this->alias, $this->schema);
3228
}
3329

30+
#[Override]
3431
public function verifyConnectivity(?SessionConfiguration $config = null): bool
3532
{
3633
return $this->driver->verifyConnectivity();
3734
}
3835

36+
#[Override]
3937
public function closeConnections(): void
4038
{
4139
$this->driver->closeConnections();

src/Decorators/SymfonySession.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
use Laudis\Neo4j\Types\CypherMap;
1414
use Neo4j\Neo4jBundle\EventHandler;
1515
use Neo4j\Neo4jBundle\Factories\SymfonyDriverFactory;
16+
use Override;
1617

17-
/**
18-
* @implements SessionInterface<SummarizedResult<CypherMap>>
19-
*/
20-
class SymfonySession implements SessionInterface
18+
final class SymfonySession implements SessionInterface
2119
{
2220
public function __construct(
2321
private readonly Session $session,
@@ -28,6 +26,7 @@ public function __construct(
2826
) {
2927
}
3028

29+
#[Override]
3130
public function runStatements(iterable $statements, ?TransactionConfiguration $config = null): CypherList
3231
{
3332
$tbr = [];
@@ -38,7 +37,8 @@ public function runStatements(iterable $statements, ?TransactionConfiguration $c
3837
return CypherList::fromIterable($tbr);
3938
}
4039

41-
public function runStatement(Statement $statement, ?TransactionConfiguration $config = null)
40+
#[Override]
41+
public function runStatement(Statement $statement, ?TransactionConfiguration $config = null): SummarizedResult
4242
{
4343
return $this->handler->handleQuery(
4444
runHandler: fn (Statement $statement) => $this->session->runStatement($statement),
@@ -49,11 +49,13 @@ public function runStatement(Statement $statement, ?TransactionConfiguration $co
4949
);
5050
}
5151

52-
public function run(string $statement, iterable $parameters = [], ?TransactionConfiguration $config = null)
52+
#[Override]
53+
public function run(string $statement, iterable $parameters = [], ?TransactionConfiguration $config = null): SummarizedResult
5354
{
5455
return $this->runStatement(new Statement($statement, $parameters));
5556
}
5657

58+
#[Override]
5759
public function beginTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): SymfonyTransaction
5860
{
5961
return $this->factory->createTransaction(
@@ -73,6 +75,7 @@ public function beginTransaction(?iterable $statements = null, ?TransactionConfi
7375
*
7476
* @psalm-suppress ArgumentTypeCoercion
7577
*/
78+
#[Override]
7679
public function writeTransaction(callable $tsxHandler, ?TransactionConfiguration $config = null)
7780
{
7881
return TransactionHelper::retry(
@@ -88,6 +91,7 @@ public function writeTransaction(callable $tsxHandler, ?TransactionConfiguration
8891
*
8992
* @return HandlerResult
9093
*/
94+
#[Override]
9195
public function readTransaction(callable $tsxHandler, ?TransactionConfiguration $config = null)
9296
{
9397
// TODO: create read transaction here.
@@ -101,11 +105,13 @@ public function readTransaction(callable $tsxHandler, ?TransactionConfiguration
101105
*
102106
* @return HandlerResult
103107
*/
108+
#[Override]
104109
public function transaction(callable $tsxHandler, ?TransactionConfiguration $config = null)
105110
{
106111
return $this->writeTransaction($tsxHandler, $config);
107112
}
108113

114+
#[Override]
109115
public function getLastBookmark(): Bookmark
110116
{
111117
return $this->session->getLastBookmark();

0 commit comments

Comments
 (0)