Skip to content

Commit d8c0333

Browse files
committed
improved typing
1 parent ffcc977 commit d8c0333

File tree

6 files changed

+10
-60
lines changed

6 files changed

+10
-60
lines changed

psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@
3939
</stubs>
4040
<plugins>
4141
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
42-
<pluginClass class="Lctrs\PsalmPsrContainerPlugin\Plugin"/>
4342
</plugins>
4443
</psalm>

src/Common/Cache.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
use Generator;
2121

2222
use function is_int;
23-
use function is_iterable;
2423
use function is_object;
25-
use function is_string;
2624

2725
use Laudis\Neo4j\Exception\InvalidCacheArgumentException;
2826

@@ -53,9 +51,7 @@ class Cache implements CacheInterface
5351
private array $items = [];
5452
private static ?self $instance = null;
5553

56-
private function __construct()
57-
{
58-
}
54+
private function __construct() {}
5955

6056
public static function getInstance(): self
6157
{
@@ -69,7 +65,6 @@ public static function getInstance(): self
6965
/**
7066
* @template U
7167
*
72-
* @param string $key
7368
* @param U $default
7469
*
7570
* @return T|U
@@ -102,8 +97,6 @@ public function clear(): bool
10297
*/
10398
public function deleteMultiple(iterable $keys): bool
10499
{
105-
$this->assertIterable($keys);
106-
107100
foreach ($keys as $key) {
108101
$this->delete($key);
109102
}
@@ -122,10 +115,8 @@ public function set(string $key, mixed $value, int|DateInterval|null $ttl = null
122115
$ttl = (new DateTimeImmutable())->add($ttl)->getTimestamp();
123116
} elseif ($ttl === null) {
124117
$ttl = PHP_INT_MAX;
125-
} elseif (is_int($ttl)) {
126-
$ttl += time();
127118
} else {
128-
throw new InvalidCacheArgumentException();
119+
$ttl += time();
129120
}
130121

131122
if (is_object($value)) {
@@ -150,14 +141,12 @@ public function delete($key): bool
150141
* @template U
151142
*
152143
* @param iterable<string> $keys
153-
* @param U $default
144+
* @param U $default
154145
*
155146
* @return Generator<string, T|U>
156147
*/
157148
public function getMultiple($keys, $default = null): Generator
158149
{
159-
$this->assertIterable($keys);
160-
161150
/** @var list<string> $cachedKeys */
162151
$cachedKeys = [];
163152
foreach ($keys as $key) {
@@ -173,18 +162,16 @@ public function getMultiple($keys, $default = null): Generator
173162
}
174163

175164
/**
176-
* @param iterable<string, T> $values
165+
* @param iterable<string, T> $values
177166
* @param int|DateInterval|null $ttl
178167
*
179168
* @throws InvalidCacheArgumentException
180169
*/
181170
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
182171
{
183-
$this->assertIterable($values);
184-
185172
foreach ($values as $key => $value) {
186173
if (is_int($key)) {
187-
$key = (string)$key;
174+
$key = (string) $key;
188175
}
189176
$this->set($key, $value, $ttl);
190177
}

src/Common/TransactionHelper.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ public static function retry(callable $tsxFactory, callable $tsxHandler)
5454
}
5555
}
5656

57-
/**
58-
* @param mixed $tbr
59-
*
60-
* @psalm-param U $tbr
61-
*/
6257
private static function triggerLazyResult(mixed $tbr): void
6358
{
6459
if ($tbr instanceof AbstractCypherSequence) {

src/ParameterHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ public static function asMap(iterable $iterable): CypherMap
7777

7878
/**
7979
* @return iterable|scalar|stdClass|IStructure|null
80-
*
81-
* @param \DateTime|array|object|stdClass $value
8280
*/
83-
public static function asParameter(array|object|stdClass|\DateTimed $value, bool $boltDriver = false)
84-
{
81+
public static function asParameter(
82+
mixed $value,
83+
bool $boltDriver = false
84+
): iterable|int|float|bool|string|stdClass|IStructure|null {
8585
return self::cypherMapToStdClass($value) ??
8686
self::emptySequenceToArray($value) ??
8787
self::convertBoltConvertibles($value, $boltDriver) ??
@@ -108,7 +108,7 @@ private static function stringAbleToString(mixed $value): ?string
108108
*
109109
* @pure
110110
*/
111-
private static function filterInvalidType(mixed $value)
111+
private static function filterInvalidType(mixed $value): mixed
112112
{
113113
if ($value !== null && !is_scalar($value)) {
114114
/** @psalm-suppress ImpureFunctionCall */

src/TypeCaster.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ final class TypeCaster
2828
{
2929
/**
3030
* @pure
31-
*
32-
* @param mixed $value
33-
*
34-
* @psalm-param TValue $value
3531
*/
3632
public static function toString(mixed $value): ?string
3733
{
@@ -44,10 +40,6 @@ public static function toString(mixed $value): ?string
4440

4541
/**
4642
* @pure
47-
*
48-
* @param mixed $value
49-
*
50-
* @psalm-param TValue $value
5143
*/
5244
public static function toFloat(mixed $value): ?float
5345
{
@@ -61,10 +53,6 @@ public static function toFloat(mixed $value): ?float
6153

6254
/**
6355
* @pure
64-
*
65-
* @param mixed $value
66-
*
67-
* @psalm-param TValue $value
6856
*/
6957
public static function toInt(mixed $value): ?int
7058
{
@@ -88,10 +76,6 @@ public static function toNull()
8876

8977
/**
9078
* @pure
91-
*
92-
* @param mixed $value
93-
*
94-
* @psalm-param TValue $value
9579
*/
9680
public static function toBool(mixed $value): ?bool
9781
{
@@ -107,13 +91,10 @@ public static function toBool(mixed $value): ?bool
10791
* @template T
10892
*
10993
* @param class-string<T> $class
110-
* @param mixed $value
11194
*
11295
* @return T|null
11396
*
11497
* @pure
115-
*
116-
* @psalm-param TValue $value
11798
*/
11899
public static function toClass(mixed $value, string $class): ?object
119100
{
@@ -150,10 +131,6 @@ public static function toArray(mixed $value): ?array
150131
* @return CypherList<mixed>|null
151132
*
152133
* @pure
153-
*
154-
* @param mixed $value
155-
*
156-
* @psalm-param TValue $value
157134
*/
158135
public static function toCypherList(mixed $value): ?CypherList
159136
{
@@ -166,10 +143,6 @@ public static function toCypherList(mixed $value): ?CypherList
166143

167144
/**
168145
* @return CypherMap<mixed>|null
169-
*
170-
* @param mixed $value
171-
*
172-
* @psalm-param TValue $value
173146
*/
174147
public static function toCypherMap(mixed $value): ?CypherMap
175148
{

src/Types/AbstractCypherSequence.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,6 @@ public function preload(): void
542542

543543
/**
544544
* @psalm-mutation-free
545-
*
546-
* @param (int|string) $key
547-
*
548-
* @psalm-param array-key $key
549545
*/
550546
protected function isStringable(mixed $key): bool
551547
{

0 commit comments

Comments
 (0)