[Cache] minor code update to leverage PHP 7.1

This commit is contained in:
Nicolas Grekas 2018-08-27 11:36:50 +02:00
parent 620dfdec13
commit c1bf1918ec
2 changed files with 3 additions and 2 deletions

View File

@ -52,7 +52,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
null,
CacheItem::class
);
$getId = function ($key) { return $this->getId((string) $key); };
$getId = \Closure::fromCallable(array($this, 'getId'));
$this->mergeByLifetime = \Closure::bind(
function ($deferred, $namespace, &$expiredIds) use ($getId) {
$byLifetime = array();
@ -60,6 +60,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
$expiredIds = array();
foreach ($deferred as $key => $item) {
$key = (string) $key;
if (null === $item->expiry) {
$byLifetime[0 < $item->defaultLifetime ? $item->defaultLifetime : 0][$getId($key)] = $item->value;
} elseif ($item->expiry > $now) {

View File

@ -36,7 +36,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R
private $knownTagVersions = array();
private $knownTagVersionsTtl;
public function __construct(AdapterInterface $itemsPool, AdapterInterface $tagsPool = null, $knownTagVersionsTtl = 0.15)
public function __construct(AdapterInterface $itemsPool, AdapterInterface $tagsPool = null, float $knownTagVersionsTtl = 0.15)
{
$this->pool = $itemsPool;
$this->tags = $tagsPool ?: $itemsPool;