Skip to content

Commit ba8db9b

Browse files
committed
fixed psalm typing
1 parent 47f4a38 commit ba8db9b

File tree

9 files changed

+33
-16
lines changed

9 files changed

+33
-16
lines changed

src/Bolt/BoltUnmanagedTransaction.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ public function runStatements(iterable $statements): CypherList
143143
return new CypherList($tbr);
144144
}
145145

146-
/**
147-
* @return Bolt|mixed
148-
*/
149-
private function getBolt()
146+
private function getBolt(): Bolt
150147
{
151148
return $this->connection->getImplementation();
152149
}

src/Common/TransactionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static function connectionFromSocket(
9898

9999
/**
100100
* @var array{'name': 0, 'version': 1, 'edition': 2}
101-
* @psalm-suppress PossiblyUndefinedStringArrayOffset
101+
* @psalm-suppress all
102102
*/
103103
$fields = array_flip($bolt->run(<<<'CYPHER'
104104
CALL dbms.components()

src/Contracts/FormatterInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ interface FormatterInterface
7474
public function formatBoltResult(array $meta, array $results, ConnectionInterface $connection, float $resultAvailableAfter, float $resultConsumedAfter, Statement $statement);
7575

7676
/**
77-
* @param CypherResponseSet $body
77+
* @param CypherResponseSet $body
78+
* @param iterable<Statement> $statements
7879
*
7980
* @throws JsonException
8081
*

src/Databags/ResultSummary.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class ResultSummary
2020
{
2121
private SummaryCounters $counters;
2222
private DatabaseInfo $databaseInfo;
23+
/** @var CypherList<Notification> */
2324
private CypherList $notifications;
2425
private ?Plan $plan;
2526
private ?ProfiledPlan $profiledPlan;
@@ -29,6 +30,9 @@ final class ResultSummary
2930
private float $resultConsumedAfter;
3031
private ServerInfo $serverInfo;
3132

33+
/**
34+
* @param CypherList<Notification> $notifications
35+
*/
3236
public function __construct(
3337
SummaryCounters $counters,
3438
DatabaseInfo $databaseInfo,

src/Exception/UnsupportedScheme.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
final class UnsupportedScheme extends RuntimeException
2020
{
21+
/**
22+
* @param list<string> $supportedSchemas
23+
*/
2124
public static function make(string $schema, array $supportedSchemas): self
2225
{
2326
return new self('Unsupported schema: '.$schema.', available schema\'s are: '.implode(',', $supportedSchemas));

src/Formatter/Specialised/HttpOGMArrayTranslator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ public function translate(Iterator $meta, Iterator $relationship, array $nodes,
129129
*/
130130
private function translateNode(array $nodes, int $id, CypherMap $tbr): Node
131131
{
132-
/** @var list<string> $labels */
133-
$labels = [];
132+
/** @var Vector<string> */
133+
$labels = new Vector();
134134
foreach ($nodes as $node) {
135135
if ((int) $node['id'] === $id) {
136-
$labels = $node['labels'];
136+
$labels = new Vector($node['labels']);
137137
break;
138138
}
139139
}
140140

141-
return new Node($id, new CypherList(new Vector($labels)), $tbr);
141+
return new Node($id, new CypherList($labels), $tbr);
142142
}
143143

144144
/**

src/Formatter/SummarizedResultFormatter.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
use function is_int;
1919
use Laudis\Neo4j\Contracts\ConnectionInterface;
2020
use Laudis\Neo4j\Contracts\FormatterInterface;
21-
use Laudis\Neo4j\Databags\SummarizedResult;
2221
use Laudis\Neo4j\Databags\ResultSummary;
2322
use Laudis\Neo4j\Databags\ServerInfo;
2423
use Laudis\Neo4j\Databags\Statement;
24+
use Laudis\Neo4j\Databags\SummarizedResult;
2525
use Laudis\Neo4j\Databags\SummaryCounters;
2626
use Laudis\Neo4j\Enum\QueryTypeEnum;
2727
use Laudis\Neo4j\Types\CypherList;
@@ -51,7 +51,13 @@ public function __construct(FormatterInterface $formatter)
5151
$this->formatter = $formatter;
5252
}
5353

54-
public function formatHttpStats(array $response, ConnectionInterface $connection, Statement $statement, float $resultAvailableAfter, float $resultConsumedAfter, CypherList $results): SummarizedResult
54+
/**
55+
* @param CypherResponse $response
56+
* @param T $results
57+
*
58+
* @return SummarizedResult<T>
59+
*/
60+
public function formatHttpStats(array $response, ConnectionInterface $connection, Statement $statement, float $resultAvailableAfter, float $resultConsumedAfter, $results): SummarizedResult
5561
{
5662
if (!isset($response['stats'])) {
5763
throw new UnexpectedValueException('No stats found in the response set');
@@ -163,13 +169,15 @@ public function formatBoltResult(array $meta, array $results, ConnectionInterfac
163169

164170
public function formatHttpResult(ResponseInterface $response, array $body, ConnectionInterface $connection, float $resultsAvailableAfter, float $resultsConsumedAfter, iterable $statements): CypherList
165171
{
166-
/** @var Vector<SummarizedResult> $tbr */
172+
/** @var Vector<SummarizedResult<T>> */
167173
$tbr = new Vector();
168174

169175
$toDecorate = $this->formatter->formatHttpResult($response, $body, $connection, $resultsAvailableAfter, $resultsConsumedAfter, $statements);
170-
foreach ($statements as $i => $statement) {
176+
$i = 0;
177+
foreach ($statements as $statement) {
171178
$result = $body['results'][$i];
172179
$tbr->push($this->formatHttpStats($result, $connection, $statement, $resultsAvailableAfter, $resultsConsumedAfter, $toDecorate->get($i)));
180+
++$i;
173181
}
174182

175183
return new CypherList($tbr);

src/Types/CypherList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ final class CypherList implements CypherContainerInterface
2929
private Vector $vector;
3030

3131
/**
32-
* @param iterable<T> $vector
32+
* @param Vector<T> $vector
3333
*/
34-
public function __construct(iterable $vector)
34+
public function __construct(Vector $vector)
3535
{
3636
$this->vector = new Vector($vector);
3737
}

src/Types/CypherMap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public function intersect($map): CypherMap
157157
$map = $map->map;
158158
}
159159

160+
/** @var Map<string, T> $map */
160161
return new CypherMap($this->map->intersect($map));
161162
}
162163

@@ -171,6 +172,7 @@ public function diff($map): CypherMap
171172
$map = $map->map;
172173
}
173174

175+
/** @var Map<string, T> $map */
174176
return new CypherMap($this->map->diff($map));
175177
}
176178

@@ -319,6 +321,7 @@ public function union($map): CypherMap
319321
$map = $map->map;
320322
}
321323

324+
/** @var Map<string, T> $map */
322325
return new CypherMap($this->map->union($map));
323326
}
324327

@@ -333,6 +336,7 @@ public function xor($map): CypherMap
333336
$map = $map->map;
334337
}
335338

339+
/** @var Map<string, T> $map */
336340
return new CypherMap($this->map->xor($map));
337341
}
338342

0 commit comments

Comments
 (0)