Skip to content

Commit f895ceb

Browse files
committed
removed all uses of php ds
1 parent 7c6e4d3 commit f895ceb

File tree

5 files changed

+63
-69
lines changed

5 files changed

+63
-69
lines changed

src/Formatter/BasicFormatter.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use function array_slice;
1717
use Bolt\structures\Path;
1818
use function count;
19-
use Ds\Map;
20-
use Ds\Vector;
2119
use function get_class;
2220
use function gettype;
2321
use function is_array;
@@ -53,22 +51,22 @@ public function formatBoltResult(array $meta, array $results, ?ConnectionInterfa
5351
{
5452
$results = array_slice($results, 0, count($results) - 1);
5553

56-
/** @var Vector<CypherMap<scalar|array|null>> */
57-
$tbr = new Vector();
54+
/** @var list<CypherMap<scalar|array|null>> */
55+
$tbr = [];
5856
foreach ($results as $result) {
59-
$tbr->push($this->formatRow($meta, $result));
57+
$tbr[] = $this->formatRow($meta, $result);
6058
}
6159

6260
return new CypherList($tbr);
6361
}
6462

6563
public function formatHttpResult(ResponseInterface $response, array $body, ?ConnectionInterface $connection = null, ?float $resultsAvailableAfter = null, ?float $resultsConsumedAfter = null, ?iterable $statements = null): CypherList
6664
{
67-
/** @var Vector<CypherList<CypherMap<scalar|array|null>>> */
68-
$tbr = new Vector();
65+
/** @var list<CypherList<CypherMap<scalar|array|null>>> */
66+
$tbr = [];
6967

7068
foreach ($body['results'] as $results) {
71-
$tbr->push($this->buildResult($results));
69+
$tbr[] = $this->buildResult($results);
7270
}
7371

7472
return new CypherList($tbr);
@@ -81,19 +79,19 @@ public function formatHttpResult(ResponseInterface $response, array $body, ?Conn
8179
*/
8280
private function buildResult(array $result): CypherList
8381
{
84-
/** @psalm-var Vector<CypherMap<null|scalar|array>> */
85-
$tbr = new Vector();
82+
/** @var list<CypherMap<scalar|array|null>> */
83+
$tbr = [];
8684

8785
$columns = $result['columns'];
8886
foreach ($result['data'] as $dataRow) {
8987
$row = $dataRow['row'];
90-
/** @psalm-var Map<string,null|scalar|array> $map */
91-
$map = new Map();
92-
$vector = new Vector($row);
88+
/** @var array<string, scalar|array|null> $map */
89+
$map = [];
90+
$vector = $row;
9391
foreach ($columns as $index => $key) {
94-
$map->put($key, $vector->get($index));
92+
$map[$key] = $vector[$index];
9593
}
96-
$tbr->push(new CypherMap($map));
94+
$tbr[] = new CypherMap($map);
9795
}
9896

9997
return new CypherList($tbr);
@@ -106,10 +104,10 @@ private function buildResult(array $result): CypherList
106104
*/
107105
private function formatRow(array $meta, array $result): CypherMap
108106
{
109-
/** @var Map<string, scalar|array|null> $map */
110-
$map = new Map();
107+
/** @var array<string, scalar|array|null> $map */
108+
$map = [];
111109
foreach ($meta['fields'] as $i => $column) {
112-
$map->put($column, $this->mapValue($result[$i]));
110+
$map[$column] = $this->mapValue($result[$i]);
113111
}
114112

115113
return new CypherMap($map);

src/Formatter/OGMFormatter.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use function array_slice;
1717
use ArrayIterator;
1818
use function count;
19-
use Ds\Map;
20-
use Ds\Vector;
2119
use Exception;
2220
use Laudis\Neo4j\Contracts\ConnectionInterface;
2321
use Laudis\Neo4j\Contracts\FormatterInterface;
@@ -81,11 +79,11 @@ public function formatBoltResult(array $meta, array $results, ConnectionInterfac
8179
/** @var list<list<mixed>> $results */
8280
$results = array_slice($results, 0, count($results) - 1);
8381

84-
/** @var Vector<CypherMap<OGMTypes>> $tbr */
85-
$tbr = new Vector();
82+
/** @var list<CypherMap<OGMTypes>> $tbr */
83+
$tbr = [];
8684

8785
foreach ($results as $result) {
88-
$tbr->push($this->formatRow($meta, $result));
86+
$tbr[] = $this->formatRow($meta, $result);
8987
}
9088

9189
return new CypherList($tbr);
@@ -96,12 +94,12 @@ public function formatBoltResult(array $meta, array $results, ConnectionInterfac
9694
*/
9795
public function formatHttpResult(ResponseInterface $response, array $body, ConnectionInterface $connection, float $resultsAvailableAfter, float $resultsConsumedAfter, iterable $statements): CypherList
9896
{
99-
/** @var Vector<CypherList<CypherMap<OGMTypes>>> $tbr */
100-
$tbr = new Vector();
97+
/** @var list<CypherList<CypherMap<OGMTypes>>> $tbr */
98+
$tbr = [];
10199

102100
foreach ($body['results'] as $results) {
103101
/** @var CypherResult $results */
104-
$tbr->push($this->buildResult($results));
102+
$tbr[] = $this->buildResult($results);
105103
}
106104

107105
return new CypherList($tbr);
@@ -116,22 +114,22 @@ public function formatHttpResult(ResponseInterface $response, array $body, Conne
116114
*/
117115
private function buildResult(array $result): CypherList
118116
{
119-
/** @var Vector<CypherMap<OGMTypes>> $tbr */
120-
$tbr = new Vector();
117+
/** @var list<CypherMap<OGMTypes>> $tbr */
118+
$tbr = [];
121119

122120
$columns = $result['columns'];
123121
foreach ($result['data'] as $data) {
124122
$meta = new ArrayIterator($data['meta']);
125123
$nodes = $data['graph']['nodes'];
126124
$relationship = new ArrayIterator($data['graph']['relationships']);
127125

128-
/** @var Map<string, OGMTypes> $record */
129-
$record = new Map();
126+
/** @var array<string, OGMTypes> $record */
127+
$record = [];
130128
foreach ($data['row'] as $i => $value) {
131-
$record->put($columns[$i], $this->httpTranslator->translate($meta, $relationship, $nodes, $value));
129+
$record[$columns[$i]] = $this->httpTranslator->translate($meta, $relationship, $nodes, $value);
132130
}
133131

134-
$tbr->push(new CypherMap($record));
132+
$tbr[] = new CypherMap($record);
135133
}
136134

137135
return new CypherList($tbr);
@@ -145,10 +143,10 @@ private function buildResult(array $result): CypherList
145143
*/
146144
private function formatRow(array $meta, array $result): CypherMap
147145
{
148-
/** @var Map<string, OGMTypes> $map */
149-
$map = new Map();
146+
/** @var array<string, OGMTypes> $map */
147+
$map = [];
150148
foreach ($meta['fields'] as $i => $column) {
151-
$map->put($column, $this->boltTranslator->mapValueToType($result[$i]));
149+
$map[$column] = $this->boltTranslator->mapValueToType($result[$i]);
152150
}
153151

154152
return new CypherMap($map);

src/Formatter/Specialised/BoltOGMTranslator.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
use Bolt\structures\Relationship as BoltRelationship;
2626
use Bolt\structures\Time as BoltTime;
2727
use function call_user_func;
28-
use Ds\Map;
29-
use Ds\Vector;
3028
use Laudis\Neo4j\Types\Cartesian3DPoint;
3129
use Laudis\Neo4j\Types\CartesianPoint;
3230
use Laudis\Neo4j\Types\CypherList;
@@ -77,22 +75,22 @@ public function __construct()
7775

7876
private function makeFromBoltNode(BoltNode $node): Node
7977
{
80-
/** @var Map<string, OGMTypes> $properties */
81-
$properties = new Map();
78+
/** @var array<string, OGMTypes> $properties */
79+
$properties = [];
8280
/**
8381
* @var string $name
8482
* @var mixed $property
8583
*/
8684
foreach ($node->properties() as $name => $property) {
87-
$properties->put($name, $this->mapValueToType($property));
85+
$properties[$name] = $this->mapValueToType($property);
8886
}
8987

9088
/**
9189
* @psalm-suppress MixedArgumentTypeCoercion
9290
*/
9391
return new Node(
9492
$node->id(),
95-
new CypherList(new Vector($node->labels())),
93+
new CypherList($node->labels()),
9694
new CypherMap($properties)
9795
);
9896
}
@@ -134,14 +132,14 @@ private function makeFromBoltLocalTime(BoltLocalTime $time): LocalTime
134132

135133
private function makeFromBoltRelationship(BoltRelationship $rel): Relationship
136134
{
137-
/** @var Map<string, OGMTypes> $map */
138-
$map = new Map();
135+
/** @var array<string, OGMTypes> $map */
136+
$map = [];
139137
/**
140138
* @var string $key
141139
* @var mixed $property
142140
*/
143141
foreach ($rel->properties() as $key => $property) {
144-
$map->put($key, $this->mapValueToType($property));
142+
$map[$key] = $this->mapValueToType($property);
145143
}
146144

147145
return new Relationship(
@@ -166,9 +164,9 @@ private function makeFromBoltPoint3D(BoltPoint3D $x): Cartesian3DPoint
166164
private function makeFromBoltPath(BoltPath $path): Path
167165
{
168166
return new Path(
169-
new CypherList(new Vector($path->ids())),
170-
new CypherList(new Vector($path->rels())),
171-
new CypherList(new Vector($path->nodes()))
167+
new CypherList($path->ids()),
168+
new CypherList($path->rels()),
169+
new CypherList($path->nodes())
172170
);
173171
}
174172

@@ -178,24 +176,24 @@ private function makeFromBoltPath(BoltPath $path): Path
178176
private function mapArray(array $value)
179177
{
180178
if (isset($value[0])) {
181-
/** @var Vector<OGMTypes> $vector */
182-
$vector = new Vector();
179+
/** @var array<OGMTypes> $vector */
180+
$vector = [];
183181
/** @var mixed $x */
184182
foreach ($value as $x) {
185-
$vector->push($this->mapValueToType($x));
183+
$vector[] = $this->mapValueToType($x);
186184
}
187185

188186
return new CypherList($vector);
189187
}
190188

191-
/** @var Map<string, OGMTypes> */
192-
$map = new Map();
189+
/** @var array<string, OGMTypes> */
190+
$map = [];
193191
/**
194192
* @var string $key
195193
* @var mixed $x
196194
*/
197195
foreach ($value as $key => $x) {
198-
$map->put($key, $this->mapValueToType($x));
196+
$map[$key] = $this->mapValueToType($x);
199197
}
200198

201199
return new CypherMap($map);

src/Formatter/Specialised/HttpOGMArrayTranslator.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ private function relationship(Iterator $relationship): Relationship
4343
{
4444
$rel = $relationship->current();
4545
$relationship->next();
46-
/** @var Map<string, OGMTypes> $map */
47-
$map = new Map();
46+
/** @var array<string, OGMTypes> $map */
47+
$map = [];
4848
foreach ($rel['properties'] ?? [] as $key => $x) {
4949
// We only need to recurse over array types.
5050
// Nested types gets erased in the legacy http api.
5151
// We need to use JOLT instead for finer control,
5252
// which will be a different translator.
5353
if (is_array($x)) {
54-
$map->put($key, $this->translateContainer($x));
54+
$map[$key] = $this->translateContainer($x);
5555
} else {
56-
$map->put($key, $x);
56+
$map[$key] = $x;
5757
}
5858
}
5959

@@ -73,18 +73,18 @@ private function relationship(Iterator $relationship): Relationship
7373
*/
7474
private function translateCypherList(array $value): CypherList
7575
{
76-
/** @var Vector<OGMTypes> $tbr */
77-
$tbr = new Vector();
76+
/** @var array<OGMTypes> $tbr */
77+
$tbr = [];
7878
foreach ($value as $x) {
7979
// We only need to recurse over array types.
8080
// Nested types gets erased in the legacy http api.
8181
// We need to use JOLT instead for finer control,
8282
// which will be a different translator.
8383
if (is_array($x)) {
8484
/** @var array<array-key, array|scalar|null> $x */
85-
$tbr->push($this->translateContainer($x));
85+
$tbr[] = $this->translateContainer($x);
8686
} else {
87-
$tbr->push($x);
87+
$tbr[] = $x;
8888
}
8989
}
9090

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

src/Formatter/SummarizedResultFormatter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function formatHttpStats(array $response, ConnectionInterface $connection
8383
$summary = new ResultSummary(
8484
$counters,
8585
$connection->getDatabaseInfo(),
86-
new CypherList(new Vector()),
86+
new CypherList(),
8787
null,
8888
null,
8989
$statement,
@@ -149,7 +149,7 @@ public function formatBoltResult(array $meta, array $results, ConnectionInterfac
149149
$summary = new ResultSummary(
150150
$counters,
151151
$connection->getDatabaseInfo(),
152-
new CypherList(new Vector()),
152+
new CypherList(),
153153
null,
154154
null,
155155
$statement,
@@ -169,14 +169,14 @@ public function formatBoltResult(array $meta, array $results, ConnectionInterfac
169169

170170
public function formatHttpResult(ResponseInterface $response, array $body, ConnectionInterface $connection, float $resultsAvailableAfter, float $resultsConsumedAfter, iterable $statements): CypherList
171171
{
172-
/** @var Vector<SummarizedResult<T>> */
173-
$tbr = new Vector();
172+
/** @var list<SummarizedResult<T>> */
173+
$tbr = [];
174174

175175
$toDecorate = $this->formatter->formatHttpResult($response, $body, $connection, $resultsAvailableAfter, $resultsConsumedAfter, $statements);
176176
$i = 0;
177177
foreach ($statements as $statement) {
178178
$result = $body['results'][$i];
179-
$tbr->push($this->formatHttpStats($result, $connection, $statement, $resultsAvailableAfter, $resultsConsumedAfter, $toDecorate->get($i)));
179+
$tbr[] = $this->formatHttpStats($result, $connection, $statement, $resultsAvailableAfter, $resultsConsumedAfter, $toDecorate->get($i));
180180
++$i;
181181
}
182182

0 commit comments

Comments
 (0)