Skip to content

Commit 97fa806

Browse files
authored
Merge pull request #770 from Geolim4/master
Fixed #768 (v8)
2 parents 99a345a + b3ec4c2 commit 97fa806

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/Phpfastcache/Helper/Psr16Adapter.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@
1919
use DateInterval;
2020
use DateTime;
2121
use Phpfastcache\CacheManager;
22+
use Phpfastcache\Config\ConfigurationOptionInterface;
2223
use Phpfastcache\Core\Item\ExtendedCacheItemInterface;
2324
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
2425
use Phpfastcache\Exceptions\{PhpfastcacheDriverCheckException,
2526
PhpfastcacheInvalidArgumentException,
2627
PhpfastcacheLogicException,
2728
PhpfastcacheRootException,
28-
PhpfastcacheSimpleCacheException
29-
};
29+
PhpfastcacheSimpleCacheException};
3030
use Psr\SimpleCache\CacheInterface;
3131
use Traversable;
3232

33-
3433
/**
3534
* Class Psr16Adapter
3635
* @package phpFastCache\Helper
@@ -45,7 +44,7 @@ class Psr16Adapter implements CacheInterface
4544
/**
4645
* Psr16Adapter constructor.
4746
* @param $driver
48-
* @param null $config
47+
* @param null|ConfigurationOptionInterface $config
4948
* @throws PhpfastcacheDriverCheckException
5049
* @throws PhpfastcacheInvalidArgumentException
5150
* @throws PhpfastcacheLogicException
@@ -54,7 +53,7 @@ class Psr16Adapter implements CacheInterface
5453
* @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException
5554
* @throws \ReflectionException
5655
*/
57-
public function __construct($driver, $config = null)
56+
public function __construct($driver, ConfigurationOptionInterface $config = null)
5857
{
5958
if ($driver instanceof ExtendedCacheItemPoolInterface) {
6059
if ($config !== null) {
@@ -68,7 +67,7 @@ public function __construct($driver, $config = null)
6867

6968
/**
7069
* @param string $key
71-
* @param null $default
70+
* @param mixed|null $default
7271
* @return mixed|null
7372
* @throws PhpfastcacheSimpleCacheException
7473
* @throws \Psr\Cache\InvalidArgumentException
@@ -90,7 +89,7 @@ public function get($key, $default = null)
9089
/**
9190
* @param string $key
9291
* @param mixed $value
93-
* @param null $ttl
92+
* @param null|int|DateInterval $ttl
9493
* @return bool
9594
* @throws PhpfastcacheSimpleCacheException
9695
* @throws \Psr\Cache\InvalidArgumentException
@@ -103,7 +102,7 @@ public function set($key, $value, $ttl = null): bool
103102
->set($value);
104103
if (\is_int($ttl) && $ttl <= 0) {
105104
$cacheItem->expiresAt((new DateTime('@0')));
106-
} elseif (\is_int($ttl) || $ttl instanceof DateInterval) {
105+
} elseif ($ttl !== null) {
107106
$cacheItem->expiresAfter($ttl);
108107
}
109108
return $this->internalCacheInstance->save($cacheItem);
@@ -142,7 +141,7 @@ public function clear(): bool
142141
/**
143142
* @param iterable $keys
144143
* @param null $default
145-
* @return array|iterable
144+
* @return ExtendedCacheItemInterface[]|iterable
146145
* @throws PhpfastcacheSimpleCacheException
147146
* @throws \Psr\Cache\InvalidArgumentException
148147
*/
@@ -153,7 +152,7 @@ public function getMultiple($keys, $default = null)
153152
}
154153
try {
155154
return \array_map(
156-
function (ExtendedCacheItemInterface $item) {
155+
static function (ExtendedCacheItemInterface $item) {
157156
return $item->get();
158157
},
159158
$this->internalCacheInstance->getItems($keys)
@@ -168,6 +167,7 @@ function (ExtendedCacheItemInterface $item) {
168167
* @param null|int|DateInterval $ttl
169168
* @return bool
170169
* @throws PhpfastcacheSimpleCacheException
170+
* @throws \Psr\Cache\InvalidArgumentException
171171
*/
172172
public function setMultiple($values, $ttl = null): bool
173173
{
@@ -177,7 +177,7 @@ public function setMultiple($values, $ttl = null): bool
177177

178178
if (\is_int($ttl) && $ttl <= 0) {
179179
$cacheItem->expiresAt((new DateTime('@0')));
180-
} elseif (\is_int($ttl) || $ttl instanceof DateInterval) {
180+
} elseif ($ttl !== null) {
181181
$cacheItem->expiresAfter($ttl);
182182
}
183183
$this->internalCacheInstance->saveDeferred($cacheItem);
@@ -190,7 +190,7 @@ public function setMultiple($values, $ttl = null): bool
190190
}
191191

192192
/**
193-
* @param iterable $keys
193+
* @param iterable|array $keys
194194
* @return bool
195195
* @throws PhpfastcacheSimpleCacheException
196196
* @throws \Psr\Cache\InvalidArgumentException
@@ -199,7 +199,7 @@ public function deleteMultiple($keys): bool
199199
{
200200
try {
201201
if ($keys instanceof Traversable) {
202-
return $this->internalCacheInstance->deleteItems(iterator_to_array($keys));
202+
return $this->internalCacheInstance->deleteItems(\iterator_to_array($keys));
203203
} elseif (\is_array($keys)) {
204204
return $this->internalCacheInstance->deleteItems($keys);
205205
} else {

0 commit comments

Comments
 (0)