Skip to content

Commit 6d18818

Browse files
committed
psalm http
1 parent ec9435e commit 6d18818

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

src/Types/Abstract3DPoint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function getZ(): float
4848
}
4949

5050
/**
51+
* @psalm-suppress ImplementedReturnTypeMismatch
5152
* @return array{x: float, y: float, z: float, srid: int, crs: Crs}
5253
*/
5354
public function toArray(): array

src/Types/AbstractCypherSequence.php

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

1414
namespace Laudis\Neo4j\Types;
1515

16+
use Generator;
1617
use function array_key_exists;
1718
use function array_reverse;
1819

@@ -70,20 +71,20 @@ abstract class AbstractCypherSequence implements Countable, JsonSerializable, Ar
7071
protected int $generatorPosition = 0;
7172

7273
/**
73-
* @var (callable():(\Iterator<TKey, TValue>))|\Iterator<TKey, TValue>
74+
* @var (callable():(Iterator<TKey, TValue>))|Iterator<TKey, TValue>
7475
*/
7576
protected $generator;
7677

7778
/**
7879
* @template Value
7980
*
80-
* @param callable():(\Generator<mixed, Value>) $operation
81+
* @param callable():(Generator<mixed, Value>) $operation
8182
*
8283
* @return static<Value, TKey>
8384
*
8485
* @psalm-mutation-free
8586
*/
86-
abstract protected function withOperation($operation): self;
87+
abstract protected function withOperation(callable $operation): self;
8788

8889
/**
8990
* Copies the sequence.
@@ -282,7 +283,7 @@ public function sorted(?callable $comparator = null): self
282283
return $this->withOperation(function () use ($comparator) {
283284
$iterable = $this->toArray();
284285

285-
if ($comparator) {
286+
if ($comparator !== null) {
286287
uasort($iterable, $comparator);
287288
} else {
288289
asort($iterable);
@@ -298,6 +299,7 @@ public function sorted(?callable $comparator = null): self
298299
* @return ArrayList<mixed>
299300
*
300301
* @psalm-mutation-free
302+
* @psalm-suppress MixedArrayAccess
301303
*/
302304
public function pluck(string $key): ArrayList
303305
{
@@ -318,6 +320,7 @@ public function pluck(string $key): ArrayList
318320
* @return Map<mixed>
319321
*
320322
* @psalm-mutation-free
323+
* @psalm-suppress MixedArrayAccess
321324
*/
322325
public function keyBy(string $key): Map
323326
{
@@ -467,6 +470,7 @@ public function next(): void
467470
$generator->next();
468471

469472
if ($generator->valid()) {
473+
/** @var TKey */
470474
$this->keyCache[] = $generator->key();
471475
$this->cache[$generator->key()] = $generator->current();
472476
}
@@ -520,14 +524,16 @@ private function setupCache(): void
520524
{
521525
$generator = $this->getGenerator();
522526

523-
if (count($this->cache) !== 0 && count($this->cache) % ($this->cacheLimit + 1) === 0) {
527+
if (count($this->keyCache) !== 0 && count($this->cache) !== 0 && count($this->cache) % ($this->cacheLimit + 1) === 0) {
524528
$this->cache = [array_key_last($this->cache) => $this->cache[array_key_last($this->cache)]];
525529
$this->keyCache = [$this->keyCache[array_key_last($this->keyCache)]];
526530
}
527531

528532
if ($this->cache === [] && $generator->valid()) {
529-
$this->cache[$generator->key()] = $generator->current();
530-
$this->keyCache[] = $generator->key();
533+
/** @var TKey $key */
534+
$key = $generator->key();
535+
$this->cache[$key] = $generator->current();
536+
$this->keyCache[] = $key;
531537
}
532538
}
533539

src/Types/AbstractPoint.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* @psalm-immutable
2727
*
2828
* @psalm-import-type Crs from PointInterface
29+
*
30+
* @extends AbstractPropertyObject<float|int|string, float|int|string>
2931
*/
3032
abstract class AbstractPoint extends AbstractPropertyObject implements PointInterface, BoltConvertibleInterface
3133
{

src/Types/ArrayList.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public function last()
106106
*
107107
* @param iterable<mixed, NewValue> $values
108108
*
109+
* @psalm-suppress LessSpecificImplementedReturnType
110+
* @psalm-suppress ImplementedReturnTypeMismatch
111+
*
109112
* @return static<TValue|NewValue>
110113
*
111114
* @psalm-mutation-free

src/Types/Map.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,14 @@ public function xor(iterable $map): Map
245245
*
246246
* @param iterable<mixed, NewValue> $values
247247
*
248+
* @psalm-suppress LessSpecificImplementedReturnType
249+
*
248250
* @return self<TValue|NewValue>
249251
*
250252
* @psalm-mutation-free
251253
*/
252254
public function merge(iterable $values): Map
253255
{
254-
/** @var self<TValue|NewValue> */
255256
return $this->withOperation(function () use ($values) {
256257
$tbr = $this->toArray();
257258
$values = Map::fromIterable($values);

0 commit comments

Comments
 (0)