Skip to content

Commit ffcc977

Browse files
committed
reduce hour instead of increase in test results
1 parent d29389d commit ffcc977

File tree

6 files changed

+64
-44
lines changed

6 files changed

+64
-44
lines changed

src/Common/Cache.php

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ class Cache implements CacheInterface
5353
private array $items = [];
5454
private static ?self $instance = null;
5555

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

5860
public static function getInstance(): self
5961
{
@@ -68,11 +70,11 @@ public static function getInstance(): self
6870
* @template U
6971
*
7072
* @param string $key
71-
* @param U $default
73+
* @param U $default
7274
*
7375
* @return T|U
7476
*/
75-
public function get($key, $default = null)
77+
public function get(string $key, mixed $default = null): mixed
7678
{
7779
$this->assertValidKey($key);
7880

@@ -98,7 +100,7 @@ public function clear(): bool
98100
*
99101
* @throws InvalidCacheArgumentException
100102
*/
101-
public function deleteMultiple($keys): bool
103+
public function deleteMultiple(iterable $keys): bool
102104
{
103105
$this->assertIterable($keys);
104106

@@ -110,11 +112,9 @@ public function deleteMultiple($keys): bool
110112
}
111113

112114
/**
113-
* @param string $key
114-
* @param T $value
115-
* @param int|DateInterval|null $ttl
115+
* @param T $value
116116
*/
117-
public function set($key, $value, $ttl = null): bool
117+
public function set(string $key, mixed $value, int|DateInterval|null $ttl = null): bool
118118
{
119119
$this->assertValidKey($key);
120120

@@ -150,7 +150,7 @@ public function delete($key): bool
150150
* @template U
151151
*
152152
* @param iterable<string> $keys
153-
* @param U $default
153+
* @param U $default
154154
*
155155
* @return Generator<string, T|U>
156156
*/
@@ -173,18 +173,18 @@ public function getMultiple($keys, $default = null): Generator
173173
}
174174

175175
/**
176-
* @param iterable<string, T> $values
176+
* @param iterable<string, T> $values
177177
* @param int|DateInterval|null $ttl
178178
*
179179
* @throws InvalidCacheArgumentException
180180
*/
181-
public function setMultiple($values, $ttl = null): bool
181+
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
182182
{
183183
$this->assertIterable($values);
184184

185185
foreach ($values as $key => $value) {
186186
if (is_int($key)) {
187-
$key = (string) $key;
187+
$key = (string)$key;
188188
}
189189
$this->set($key, $value, $ttl);
190190
}
@@ -193,38 +193,20 @@ public function setMultiple($values, $ttl = null): bool
193193
}
194194

195195
/**
196-
* @param-out string $key
197-
*
198-
* @throws InvalidCacheArgumentException
199-
*/
200-
private function assertValidKey(mixed $key): void
201-
{
202-
if (is_string($key)) {
203-
if ($key === '' ||
204-
str_contains($key, '{') ||
205-
str_contains($key, '}') ||
206-
str_contains($key, '(') ||
207-
str_contains($key, ')') ||
208-
str_contains($key, '/') ||
209-
str_contains($key, '\\') ||
210-
str_contains($key, '@') ||
211-
str_contains($key, ':')
212-
) {
213-
throw new InvalidCacheArgumentException();
214-
}
215-
} else {
216-
throw new InvalidCacheArgumentException();
217-
}
218-
}
219-
220-
/**
221-
* @param-out iterable<string> $keys
222-
*
223196
* @throws InvalidCacheArgumentException
224197
*/
225-
private function assertIterable(mixed $keys): void
198+
private function assertValidKey(string $key): void
226199
{
227-
if (!is_iterable($keys)) {
200+
if ($key === '' ||
201+
str_contains($key, '{') ||
202+
str_contains($key, '}') ||
203+
str_contains($key, '(') ||
204+
str_contains($key, ')') ||
205+
str_contains($key, '/') ||
206+
str_contains($key, '\\') ||
207+
str_contains($key, '@') ||
208+
str_contains($key, ':')
209+
) {
228210
throw new InvalidCacheArgumentException();
229211
}
230212
}

src/Common/TransactionHelper.php

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

57+
/**
58+
* @param mixed $tbr
59+
*
60+
* @psalm-param U $tbr
61+
*/
5762
private static function triggerLazyResult(mixed $tbr): void
5863
{
5964
if ($tbr instanceof AbstractCypherSequence) {

src/ParameterHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ public static function asMap(iterable $iterable): CypherMap
7777

7878
/**
7979
* @return iterable|scalar|stdClass|IStructure|null
80+
*
81+
* @param \DateTime|array|object|stdClass $value
8082
*/
81-
public static function asParameter(mixed $value, bool $boltDriver = false)
83+
public static function asParameter(array|object|stdClass|\DateTimed $value, bool $boltDriver = false)
8284
{
8385
return self::cypherMapToStdClass($value) ??
8486
self::emptySequenceToArray($value) ??

src/TypeCaster.php

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

4145
/**
4246
* @pure
47+
*
48+
* @param mixed $value
49+
*
50+
* @psalm-param TValue $value
4351
*/
4452
public static function toFloat(mixed $value): ?float
4553
{
@@ -53,6 +61,10 @@ public static function toFloat(mixed $value): ?float
5361

5462
/**
5563
* @pure
64+
*
65+
* @param mixed $value
66+
*
67+
* @psalm-param TValue $value
5668
*/
5769
public static function toInt(mixed $value): ?int
5870
{
@@ -76,6 +88,10 @@ public static function toNull()
7688

7789
/**
7890
* @pure
91+
*
92+
* @param mixed $value
93+
*
94+
* @psalm-param TValue $value
7995
*/
8096
public static function toBool(mixed $value): ?bool
8197
{
@@ -91,10 +107,13 @@ public static function toBool(mixed $value): ?bool
91107
* @template T
92108
*
93109
* @param class-string<T> $class
110+
* @param mixed $value
94111
*
95112
* @return T|null
96113
*
97114
* @pure
115+
*
116+
* @psalm-param TValue $value
98117
*/
99118
public static function toClass(mixed $value, string $class): ?object
100119
{
@@ -131,6 +150,10 @@ public static function toArray(mixed $value): ?array
131150
* @return CypherList<mixed>|null
132151
*
133152
* @pure
153+
*
154+
* @param mixed $value
155+
*
156+
* @psalm-param TValue $value
134157
*/
135158
public static function toCypherList(mixed $value): ?CypherList
136159
{
@@ -143,6 +166,10 @@ public static function toCypherList(mixed $value): ?CypherList
143166

144167
/**
145168
* @return CypherMap<mixed>|null
169+
*
170+
* @param mixed $value
171+
*
172+
* @psalm-param TValue $value
146173
*/
147174
public static function toCypherMap(mixed $value): ?CypherMap
148175
{

src/Types/AbstractCypherSequence.php

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

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

tests/Integration/OGMFormatterIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function testDateTime(string $alias): void
246246
if ($createdAt->isLegacy()) {
247247
self::assertEquals(1_559_414_432, $createdAt->getSeconds());
248248
} else {
249-
self::assertEquals(1_559_418_032, $createdAt->getSeconds());
249+
self::assertEquals(1_559_410_832, $createdAt->getSeconds());
250250
}
251251

252252
self::assertEquals(142_000_000, $createdAt->getNanoseconds());
@@ -258,7 +258,7 @@ public function testDateTime(string $alias): void
258258
if ($createdAt->isLegacy()) {
259259
self::assertEquals('{"seconds":1559414432,"nanoseconds":142000000,"tzOffsetSeconds":3600}', json_encode($createdAt, JSON_THROW_ON_ERROR));
260260
} else {
261-
self::assertEquals('{"seconds":1559418032,"nanoseconds":142000000,"tzOffsetSeconds":3600}', json_encode($createdAt, JSON_THROW_ON_ERROR));
261+
self::assertEquals('{"seconds":1559410832,"nanoseconds":142000000,"tzOffsetSeconds":3600}', json_encode($createdAt, JSON_THROW_ON_ERROR));
262262
}
263263

264264
self::assertInstanceOf(DateTime::class, $results[1]['created_at']);

0 commit comments

Comments
 (0)