Skip to content

Commit 3c89128

Browse files
committed
swapped isset for array_key_exists
1 parent f895ceb commit 3c89128

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Types/CypherList.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Laudis\Neo4j\Types;
1515

1616
use function array_filter;
17+
use function array_key_exists;
1718
use function array_key_last;
1819
use function array_map;
1920
use function array_reduce;
@@ -90,7 +91,7 @@ public function getIterator()
9091

9192
public function offsetExists($offset): bool
9293
{
93-
return isset($this->array[$offset]);
94+
return array_key_exists($offset, $this->array);
9495
}
9596

9697
/**
@@ -171,7 +172,7 @@ public function find($value)
171172
*/
172173
public function first()
173174
{
174-
if (!isset($this->array[0])) {
175+
if (!array_key_exists(0, $this->array)) {
175176
throw new OutOfBoundsException('Cannot grab first element of an empty list');
176177
}
177178

src/Types/CypherMap.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Laudis\Neo4j\Types;
1515

16+
use function array_key_exists;
1617
use function array_key_first;
1718
use function array_key_last;
1819
use function array_keys;
@@ -106,7 +107,7 @@ public function getIterator()
106107
*/
107108
public function offsetExists($offset): bool
108109
{
109-
return isset($this->map[$offset]);
110+
return array_key_exists($offset, $this->map);
110111
}
111112

112113
/**
@@ -174,7 +175,7 @@ public function skip(int $position): ?Pair
174175
{
175176
$keys = $this->keys();
176177

177-
if (isset($keys[$position])) {
178+
if (array_key_exists($position, $keys)) {
178179
$key = $keys[$position];
179180

180181
return new Pair($key, $this->map[$key]);
@@ -208,7 +209,7 @@ public function intersect(iterable $map): CypherMap
208209
{
209210
$tbr = [];
210211
foreach ($map as $key => $value) {
211-
if (isset($this->map[$key])) {
212+
if (array_key_exists($key, $this->map)) {
212213
$tbr[$key] = $this->map[$key];
213214
}
214215
}
@@ -226,7 +227,7 @@ public function diff($map): CypherMap
226227
$tbr = $this->map;
227228
/** @psalm-suppress UnusedForeachValue */
228229
foreach ($map as $key => $value) {
229-
if (isset($tbr[$key])) {
230+
if (array_key_exists($key, $tbr)) {
230231
unset($tbr[$key]);
231232
}
232233
}
@@ -236,7 +237,7 @@ public function diff($map): CypherMap
236237

237238
public function hasKey(string $key): bool
238239
{
239-
return isset($this->map[$key]);
240+
return array_key_exists($key, $this->map);
240241
}
241242

242243
/**
@@ -285,7 +286,7 @@ public function get(string $key, $default = null)
285286
return $this->map[$key] ?? $default;
286287
}
287288

288-
if (!isset($this->map[$key])) {
289+
if (!array_key_exists($key, $this->map)) {
289290
throw new OutOfBoundsException();
290291
}
291292

@@ -446,14 +447,14 @@ public function xor(iterable $map): CypherMap
446447
{
447448
$tbr = [];
448449
foreach ($map as $key => $value) {
449-
if (!isset($this->map[$key])) {
450+
if (!array_key_exists($key, $this->map)) {
450451
$tbr[$key] = $value;
451452
}
452453
}
453454

454455
$cypherMap = new self($map);
455456
foreach ($this->map as $key => $value) {
456-
if (!isset($cypherMap->map[$key])) {
457+
if (!array_key_exists($key, $cypherMap->map)) {
457458
$tbr[$key] = $value;
458459
}
459460
}

0 commit comments

Comments
 (0)