Fix PHP 8.1 deprecations (#2452)

* Fix PHP 8.1 deprecations

* Fix CS

* Fix CS using PHP 8.0
This commit is contained in:
jmsche 2021-12-18 18:48:07 +01:00 committed by GitHub
parent 3a6558625d
commit 443175e25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Collection;
use DateInterval;
use Psr\SimpleCache\CacheInterface;
/**
@ -14,6 +15,9 @@ class Memory implements CacheInterface
{
private $cache = [];
/**
* @return bool
*/
public function clear()
{
$this->cache = [];
@ -21,6 +25,11 @@ class Memory implements CacheInterface
return true;
}
/**
* @param string $key
*
* @return bool
*/
public function delete($key)
{
unset($this->cache[$key]);
@ -28,6 +37,11 @@ class Memory implements CacheInterface
return true;
}
/**
* @param iterable $keys
*
* @return bool
*/
public function deleteMultiple($keys)
{
foreach ($keys as $key) {
@ -37,6 +51,12 @@ class Memory implements CacheInterface
return true;
}
/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null)
{
if ($this->has($key)) {
@ -46,6 +66,12 @@ class Memory implements CacheInterface
return $default;
}
/**
* @param iterable $keys
* @param mixed $default
*
* @return iterable
*/
public function getMultiple($keys, $default = null)
{
$results = [];
@ -56,11 +82,23 @@ class Memory implements CacheInterface
return $results;
}
/**
* @param string $key
*
* @return bool
*/
public function has($key)
{
return array_key_exists($key, $this->cache);
}
/**
* @param string $key
* @param mixed $value
* @param null|DateInterval|int $ttl
*
* @return bool
*/
public function set($key, $value, $ttl = null)
{
$this->cache[$key] = $value;
@ -68,6 +106,12 @@ class Memory implements CacheInterface
return true;
}
/**
* @param iterable $values
* @param null|DateInterval|int $ttl
*
* @return bool
*/
public function setMultiple($values, $ttl = null)
{
foreach ($values as $key => $value) {