Upgrade framework
This commit is contained in:
@@ -20,8 +20,6 @@ interface CacheClearerInterface
|
||||
{
|
||||
/**
|
||||
* Clears any caches necessary.
|
||||
*
|
||||
* @param string $cacheDir The cache directory
|
||||
*/
|
||||
public function clear($cacheDir);
|
||||
public function clear(string $cacheDir);
|
||||
}
|
||||
|
||||
@@ -15,20 +15,17 @@ namespace Symfony\Component\HttpKernel\CacheClearer;
|
||||
* ChainCacheClearer.
|
||||
*
|
||||
* @author Dustin Dobervich <ddobervich@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ChainCacheClearer implements CacheClearerInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $clearers;
|
||||
private iterable $clearers;
|
||||
|
||||
/**
|
||||
* Constructs a new instance of ChainCacheClearer.
|
||||
*
|
||||
* @param array $clearers The initial clearers
|
||||
* @param iterable<mixed, CacheClearerInterface> $clearers
|
||||
*/
|
||||
public function __construct(array $clearers = array())
|
||||
public function __construct(iterable $clearers = [])
|
||||
{
|
||||
$this->clearers = $clearers;
|
||||
}
|
||||
@@ -36,20 +33,10 @@ class ChainCacheClearer implements CacheClearerInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear($cacheDir)
|
||||
public function clear(string $cacheDir)
|
||||
{
|
||||
foreach ($this->clearers as $clearer) {
|
||||
$clearer->clear($cacheDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a cache clearer to the aggregate.
|
||||
*
|
||||
* @param CacheClearerInterface $clearer
|
||||
*/
|
||||
public function add(CacheClearerInterface $clearer)
|
||||
{
|
||||
$this->clearers[] = $clearer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,29 +18,40 @@ use Psr\Cache\CacheItemPoolInterface;
|
||||
*/
|
||||
class Psr6CacheClearer implements CacheClearerInterface
|
||||
{
|
||||
private $pools = array();
|
||||
private array $pools = [];
|
||||
|
||||
public function __construct(array $pools = array())
|
||||
/**
|
||||
* @param array<string, CacheItemPoolInterface> $pools
|
||||
*/
|
||||
public function __construct(array $pools = [])
|
||||
{
|
||||
$this->pools = $pools;
|
||||
}
|
||||
|
||||
public function addPool(CacheItemPoolInterface $pool)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->pools[] = $pool;
|
||||
}
|
||||
|
||||
public function hasPool($name)
|
||||
public function hasPool(string $name): bool
|
||||
{
|
||||
return isset($this->pools[$name]);
|
||||
}
|
||||
|
||||
public function clearPool($name)
|
||||
/**
|
||||
* @throws \InvalidArgumentException If the cache pool with the given name does not exist
|
||||
*/
|
||||
public function getPool(string $name): CacheItemPoolInterface
|
||||
{
|
||||
if (!$this->hasPool($name)) {
|
||||
throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
|
||||
}
|
||||
|
||||
return $this->pools[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException If the cache pool with the given name does not exist
|
||||
*/
|
||||
public function clearPool(string $name): bool
|
||||
{
|
||||
if (!isset($this->pools[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name));
|
||||
throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
|
||||
}
|
||||
|
||||
return $this->pools[$name]->clear();
|
||||
@@ -49,7 +60,7 @@ class Psr6CacheClearer implements CacheClearerInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear($cacheDir)
|
||||
public function clear(string $cacheDir)
|
||||
{
|
||||
foreach ($this->pools as $pool) {
|
||||
$pool->clear();
|
||||
|
||||
Reference in New Issue
Block a user