Skip to content

Commit 43481c9

Browse files
authored
Merge pull request #3857 from PHPOffice/powerkiki
Restore PSR-16 Simple Cache v1 compatibility
2 parents a75022a + 63b9b97 commit 43481c9

File tree

2 files changed

+13
-43
lines changed

2 files changed

+13
-43
lines changed

src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Collection\Memory;
44

5-
use DateInterval;
65
use Psr\SimpleCache\CacheInterface;
76

87
/**
98
* This is the default implementation for in-memory cell collection.
109
*
11-
* Alternatives implementation should leverage off-memory, non-volatile storage
10+
* Alternative implementation should leverage off-memory, non-volatile storage
1211
* to reduce overall memory usage.
1312
*/
1413
class SimpleCache1 implements CacheInterface
@@ -25,14 +24,14 @@ public function clear(): bool
2524
return true;
2625
}
2726

28-
public function delete(string $key): bool
27+
public function delete($key): bool
2928
{
3029
unset($this->cache[$key]);
3130

3231
return true;
3332
}
3433

35-
public function deleteMultiple(iterable $keys): bool
34+
public function deleteMultiple($keys): bool
3635
{
3736
foreach ($keys as $key) {
3837
$this->delete($key);
@@ -41,10 +40,7 @@ public function deleteMultiple(iterable $keys): bool
4140
return true;
4241
}
4342

44-
/**
45-
* @param mixed $default
46-
*/
47-
public function get(string $key, $default = null): mixed
43+
public function get($key, $default = null): mixed
4844
{
4945
if ($this->has($key)) {
5046
return $this->cache[$key];
@@ -53,10 +49,7 @@ public function get(string $key, $default = null): mixed
5349
return $default;
5450
}
5551

56-
/**
57-
* @param mixed $default
58-
*/
59-
public function getMultiple(iterable $keys, $default = null): iterable
52+
public function getMultiple($keys, $default = null): iterable
6053
{
6154
$results = [];
6255
foreach ($keys as $key) {
@@ -66,26 +59,19 @@ public function getMultiple(iterable $keys, $default = null): iterable
6659
return $results;
6760
}
6861

69-
public function has(string $key): bool
62+
public function has($key): bool
7063
{
7164
return array_key_exists($key, $this->cache);
7265
}
7366

74-
/**
75-
* @param mixed $value
76-
* @param null|DateInterval|int $ttl
77-
*/
78-
public function set(string $key, $value, $ttl = null): bool
67+
public function set($key, $value, $ttl = null): bool
7968
{
8069
$this->cache[$key] = $value;
8170

8271
return true;
8372
}
8473

85-
/**
86-
* @param null|DateInterval|int $ttl
87-
*/
88-
public function setMultiple(iterable $values, $ttl = null): bool
74+
public function setMultiple($values, $ttl = null): bool
8975
{
9076
foreach ($values as $key => $value) {
9177
$this->set($key, $value);

src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
/**
99
* This is the default implementation for in-memory cell collection.
1010
*
11-
* Alternatives implementation should leverage off-memory, non-volatile storage
11+
* Alternative implementation should leverage off-memory, non-volatile storage
1212
* to reduce overall memory usage.
1313
*/
1414
class SimpleCache3 implements CacheInterface
1515
{
16-
/**
17-
* @var array Cell Cache
18-
*/
1916
private array $cache = [];
2017

2118
public function clear(): bool
@@ -41,10 +38,7 @@ public function deleteMultiple(iterable $keys): bool
4138
return true;
4239
}
4340

44-
/**
45-
* @param mixed $default
46-
*/
47-
public function get(string $key, $default = null): mixed
41+
public function get(string $key, mixed $default = null): mixed
4842
{
4943
if ($this->has($key)) {
5044
return $this->cache[$key];
@@ -53,10 +47,7 @@ public function get(string $key, $default = null): mixed
5347
return $default;
5448
}
5549

56-
/**
57-
* @param mixed $default
58-
*/
59-
public function getMultiple(iterable $keys, $default = null): iterable
50+
public function getMultiple(iterable $keys, mixed $default = null): iterable
6051
{
6152
$results = [];
6253
foreach ($keys as $key) {
@@ -71,21 +62,14 @@ public function has(string $key): bool
7162
return array_key_exists($key, $this->cache);
7263
}
7364

74-
/**
75-
* @param mixed $value
76-
* @param null|DateInterval|int $ttl
77-
*/
78-
public function set(string $key, $value, $ttl = null): bool
65+
public function set(string $key, mixed $value, null|int|DateInterval $ttl = null): bool
7966
{
8067
$this->cache[$key] = $value;
8168

8269
return true;
8370
}
8471

85-
/**
86-
* @param null|DateInterval|int $ttl
87-
*/
88-
public function setMultiple(iterable $values, $ttl = null): bool
72+
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
8973
{
9074
foreach ($values as $key => $value) {
9175
$this->set($key, $value);

0 commit comments

Comments
 (0)