Skip to content

Commit a765fe5

Browse files
committed
fixed psalm in src
1 parent dd031b8 commit a765fe5

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

src/Http/HttpDriver.php

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,6 @@
3535
*
3636
* @implements DriverInterface<T>
3737
*
38-
* @psalm-type DiscoveryResult = array{
39-
* bolt_routing:string,
40-
* transaction: string,
41-
* bolt_direct: string,
42-
* neo4j_version: string,
43-
* neo4j_edition: string,
44-
* db/cluster?: string,
45-
* dbms/cluster?: string,
46-
* data?: string
47-
* }
48-
* @psalm-type DiscoveryResultLegacy = array{
49-
* extensions: array,
50-
* node: string,
51-
* relationship: string,
52-
* node_index: string,
53-
* relationship_index: string,
54-
* extensions_info: string,
55-
* relationship_types: string,
56-
* batch: string,
57-
* cypher: string,
58-
* indexed: string,
59-
* constraints: string,
60-
* transaction: string,
61-
* node_labels: string,
62-
* neo4j_version: string
63-
* }
64-
*
6538
* @psalm-import-type OGMResults from \Laudis\Neo4j\Formatter\OGMFormatter
6639
*/
6740
final class HttpDriver implements DriverInterface
@@ -153,15 +126,17 @@ public function createSession(?SessionConfiguration $config = null): SessionInte
153126
$response = $client->sendRequest($request);
154127

155128
$discovery = HttpHelper::interpretResponse($response);
129+
/** @var string|null */
156130
$version = $discovery->neo4j_version;
157131

158132
if ($version === null) {
159-
/** @psalm-suppress PossiblyUndefinedArrayOffset */
160-
$request = $request->withUri(Uri::create($discovery->data));
161-
/** @var DiscoveryResultLegacy|DiscoveryResult */
133+
/** @var string */
134+
$uri = $discovery->data;
135+
$request = $request->withUri(Uri::create($uri));
162136
$discovery = HttpHelper::interpretResponse($client->sendRequest($request));
163137
}
164138

139+
/** @var string */
165140
$tsx = $discovery->transaction;
166141

167142
return str_replace('{databaseName}', $database, $tsx);

src/Http/HttpHelper.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ public static function interpretResponse(ResponseInterface $response): stdClass
4646
throw new Neo4jException([new Neo4jError((string) $response->getStatusCode(), $contents)]);
4747
}
4848

49+
/** @var stdClass $body */
4950
$body = json_decode($contents, false, 512, JSON_THROW_ON_ERROR);
5051

5152
$errors = [];
52-
foreach (($body->errors ?? []) as $error) {
53-
$errors[] = new Neo4jError($error->code, $error->message);
53+
/** @var list<stdClass> $bodyErrors */
54+
$bodyErrors = $body->errors ?? [];
55+
foreach ($bodyErrors as $error) {
56+
/** @var string */
57+
$code = $error->code;
58+
/** @var string */
59+
$message = $error->message;
60+
$errors[] = new Neo4jError($code, $message);
5461
}
5562

5663
if (count($errors) !== 0) {

src/Http/HttpSession.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public function beginTransaction(?iterable $statements = null, ?TransactionConfi
181181
$connection = $this->pool->acquire($request->getUri(), $this->auth, $config->getTimeout(), $this->userAgent, $this->config);
182182
$response = $connection->getImplementation()->sendRequest($request);
183183

184-
$data = HttpHelper::interpretResponse($response);
185-
186-
$path = str_replace('/commit', '', parse_url($data->commit, PHP_URL_PATH));
184+
/** @var string */
185+
$url = HttpHelper::interpretResponse($response)->commit;
186+
$path = str_replace('/commit', '', parse_url($url, PHP_URL_PATH));
187187
$uri = $request->getUri()->withPath($path);
188188
$request = $request->withUri($uri);
189189

0 commit comments

Comments
 (0)