PSR-6 Cache getItem/getItems bug
/**
* Returns a Cache Item representing the specified key.
*
* This method must always return a CacheItemInterface object, even in case of
* a cache miss. It MUST NOT return null.
*
* @param string $key
* The key for which to return the corresponding Cache Item.
*
* @throws InvalidArgumentException
* If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
* MUST be thrown.
*
* @return CacheItemInterface
* The corresponding Cache Item.
*/
public function getItem($key);
/**
* Returns a traversable set of cache items.
*
* @param string[] $keys
* An indexed array of keys of items to retrieve.
*
* @throws InvalidArgumentException
* If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
* MUST be thrown.
*
* @return array|\Traversable
* A traversable collection of Cache Items keyed by the cache keys of
* each item. A Cache item will be returned for each key, even if that
* key is not found. However, if no keys are specified then an empty
* traversable MUST be returned instead.
*/
public function getItems(array $keys = array());
Yii2Extended\Yii2Cache::getItem must always return CacheItemInterface
public function getItem($key)
{
$value = $this->_yii2Cache->get($key);
if(null === $value)
$value = new Psr6ToYii2CacheItem($key);
/** @psalm-suppress MixedReturnStatement */
return $value; # <- return cached value instead, yii2 returns false when item not exists
}
Yii2Extended\Yii2Cache::getItems must always return CacheItemInterface[] indexed by cache keys