Skip to content

Commit 3e7e3cc

Browse files
committed
fixed fix-cs and psalm errors
1 parent aad4cb6 commit 3e7e3cc

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

src/Bolt/BoltConnection.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,12 @@ public function close(): void
334334
{
335335
try {
336336
if ($this->isOpen()) {
337-
if ($this->isStreaming() && ($this->connectionUsed['reader'] || $this->connectionUsed['writer'])) {
337+
if ($this->isStreaming() && (($this->connectionUsed['reader'] ?? false) || ($this->connectionUsed['writer'] ?? false))) {
338338
$this->discardUnconsumedResults();
339339
}
340340

341341
// Only send GOODBYE if the connection was ever used
342-
if ($this->connectionUsed['reader'] || $this->connectionUsed['writer']) {
342+
if (($this->connectionUsed['reader'] ?? false) || ($this->connectionUsed['writer'] ?? false)) {
343343
$message = $this->messageFactory->createGoodbyeMessage();
344344
$message->send();
345345
}
@@ -351,7 +351,6 @@ public function close(): void
351351
}
352352
}
353353

354-
355354
private function buildRunExtra(
356355
?string $database,
357356
?float $timeout,
@@ -462,16 +461,19 @@ public function discardUnconsumedResults(): void
462461

463462
if (empty($this->subscribedResults)) {
464463
$this->logger?->log(LogLevel::DEBUG, 'No unconsumed results to discard');
464+
465465
return;
466466
}
467467

468468
$state = $this->getServerState();
469469
$this->logger?->log(LogLevel::DEBUG, "Server state before discard: {$state}");
470470

471471
// Skip discard if this connection was never used
472-
if (!$this->connectionUsed['reader'] && !$this->connectionUsed['writer']) {
472+
// Skip discard if this connection was never used
473+
if (!($this->connectionUsed['reader'] ?? false) && !($this->connectionUsed['writer'] ?? false)) {
473474
$this->logger?->log(LogLevel::DEBUG, 'Skipping discard - connection never used');
474475
$this->subscribedResults = [];
476+
475477
return;
476478
}
477479

src/Bolt/Session.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function __construct(
5858
private readonly SummarizedResultFormatter $formatter,
5959
) {
6060
$this->bookmarkHolder = new BookmarkHolder(Bookmark::from($config->getBookmarks()));
61-
6261
}
6362

6463
/**

src/Contracts/DriverInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Laudis\Neo4j\Contracts;
1515

16-
use Laudis\Neo4j\Databags\ServerInfo;
1716
use Laudis\Neo4j\Databags\SessionConfiguration;
1817
use Laudis\Neo4j\Types\CypherList;
1918
use Laudis\Neo4j\Types\CypherMap;

testkit-backend/src/Handlers/GetServerInfo.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
final class GetServerInfo implements RequestHandlerInterface
3838
{
3939
public function __construct(
40-
private MainRepository $repository
41-
) {}
40+
private MainRepository $repository,
41+
) {
42+
}
4243

4344
/**
4445
* @param GetServerInfoRequest $request
@@ -53,7 +54,6 @@ public function handle($request): TestkitResponseInterface
5354
}
5455

5556
return $this->getServerInfoFromSession($driver);
56-
5757
} catch (Exception $e) {
5858
$uuid = Uuid::v4();
5959

@@ -81,6 +81,7 @@ private function getServerInfoFromDriver($driver): ServerInfoResponse
8181
try {
8282
$pool = $this->getConnectionPool($driver);
8383
$connection = $this->acquireConnectionFromPool($pool, SessionConfiguration::default());
84+
8485
return new ServerInfoResponse($this->extractServerInfo($connection));
8586
} finally {
8687
if ($connection !== null && $pool !== null) {
@@ -120,15 +121,7 @@ private function acquireConnectionFromPool($pool, SessionConfiguration $sessionC
120121
if (method_exists($pool, 'getRoutingTable')) {
121122
$routingTable = $pool->getRoutingTable();
122123
if ($routingTable !== null && empty($routingTable->getReaders())) {
123-
throw new Neo4jException([
124-
new Neo4jError(
125-
'No readers available in routing table',
126-
'N/A',
127-
'ClientError',
128-
'Routing',
129-
'RoutingTable'
130-
)
131-
]);
124+
throw new Neo4jException([new Neo4jError('No readers available in routing table', 'N/A', 'ClientError', 'Routing', 'RoutingTable')]);
132125
}
133126
}
134127

@@ -153,8 +146,8 @@ private function extractServerInfo($connection): ServerInfo
153146
}
154147
}
155148

156-
$address = $connection->getServerAddress();
157-
$agent = $connection->getServerAgent();
149+
$address = $connection->getServerAddress();
150+
$agent = $connection->getServerAgent();
158151
$protocol = $connection->getProtocol();
159152

160153
if (empty($address) || empty($agent)) {
@@ -178,6 +171,7 @@ private function getServerInfoFromSession($driver): ServerInfoResponse
178171

179172
try {
180173
$result = $session->run('RETURN 1');
174+
181175
return new ServerInfoResponse($result->summary()->getServerInfo());
182176
} finally {
183177
$session->close();

testkit-backend/src/RequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Laudis\Neo4j\TestkitBackend;
1515

16-
use Laudis\Neo4j\TestkitBackend\Requests\GetServerInfoRequest;
1716
use function is_string;
1817

1918
use Laudis\Neo4j\TestkitBackend\Requests\AuthorizationTokenRequest;
@@ -23,6 +22,7 @@
2322
use Laudis\Neo4j\TestkitBackend\Requests\ForcedRoutingTableUpdateRequest;
2423
use Laudis\Neo4j\TestkitBackend\Requests\GetFeaturesRequest;
2524
use Laudis\Neo4j\TestkitBackend\Requests\GetRoutingTableRequest;
25+
use Laudis\Neo4j\TestkitBackend\Requests\GetServerInfoRequest;
2626
use Laudis\Neo4j\TestkitBackend\Requests\NewDriverRequest;
2727
use Laudis\Neo4j\TestkitBackend\Requests\NewSessionRequest;
2828
use Laudis\Neo4j\TestkitBackend\Requests\ResolverResolutionCompletedRequest;

testkit-backend/src/Responses/ServerInfoResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class ServerInfoResponse implements TestkitResponseInterface
2828
public function __construct(ServerInfo $serverInfo)
2929
{
3030
$uri = $serverInfo->getAddress();
31-
$this->address = $uri->getHost() . ':' . $uri->getPort();
31+
$this->address = $uri->getHost().':'.$uri->getPort();
3232

3333
$this->agent = $serverInfo->getAgent();
3434

testkit-backend/testkit.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,5 @@ python3 -m unittest tests.stub.connectivity_check.test_get_server_info.TestGetSe
152152
python3 -m unittest tests.stub.connectivity_check.test_get_server_info.TestGetServerInfo.test_routing_no_server
153153

154154

155-
156155
exit $EXIT_CODE
157156

0 commit comments

Comments
 (0)