diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index f40a9806bf..b665aed4dc 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -107,7 +107,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg * * @return AdapterInterface */ - public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) + public static function createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, LoggerInterface $logger = null) { $opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true); if (null !== $logger) { @@ -118,7 +118,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg return $opcache; } - $apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version); + $apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version); if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { $apcu->setLogger(new NullLogger()); } elseif (null !== $logger) { @@ -128,11 +128,8 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg return new ChainAdapter([$apcu, $opcache]); } - public static function createConnection($dsn, array $options = []) + public static function createConnection(string $dsn, array $options = []) { - if (!\is_string($dsn)) { - throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, \gettype($dsn))); - } if (0 === strpos($dsn, 'redis:') || 0 === strpos($dsn, 'rediss:')) { return RedisAdapter::createConnection($dsn, $options); } diff --git a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php index a9b599f05c..f7135aa148 100644 --- a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php @@ -80,7 +80,7 @@ class ApcuAdapter extends AbstractAdapter /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY)) @@ -102,7 +102,7 @@ class ApcuAdapter extends AbstractAdapter /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { try { if (false === $failures = apcu_store($values, null, $lifetime)) { diff --git a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php index 80a8713e0e..7da759d4b7 100644 --- a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php @@ -73,7 +73,7 @@ class DoctrineAdapter extends AbstractAdapter /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { $namespace = $this->provider->getNamespace(); @@ -98,7 +98,7 @@ class DoctrineAdapter extends AbstractAdapter /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { return $this->provider->saveMultiple($values, $lifetime); } diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index ce29d84bf2..a625215529 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -234,7 +234,7 @@ class MemcachedAdapter extends AbstractAdapter /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed; @@ -300,7 +300,7 @@ class MemcachedAdapter extends AbstractAdapter /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { return '' === $namespace && $this->getClient()->flush(); } diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index 2bb4c4df6c..d1c0b75a42 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -251,7 +251,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { $conn = $this->getConnection(); @@ -292,7 +292,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed; diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index ec84f5e2a1..57fb3b7311 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -199,7 +199,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { $ok = true; $expiry = $lifetime ? time() + $lifetime : 'PHP_INT_MAX'; @@ -256,7 +256,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { $this->values = []; diff --git a/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php b/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php index bb38871019..333c4af174 100644 --- a/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php +++ b/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php @@ -63,7 +63,7 @@ class Psr16Adapter extends AbstractAdapter implements PruneableInterface, Resett /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { return $this->pool->clear(); } @@ -79,7 +79,7 @@ class Psr16Adapter extends AbstractAdapter implements PruneableInterface, Resett /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime); } diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index 0f708f0859..0467dbeb96 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -33,7 +33,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter * @param string $name * @param TraceableAdapter $instance */ - public function addInstance($name, TraceableAdapter $instance) + public function addInstance(string $name, TraceableAdapter $instance) { $this->instances[$name] = $instance; } diff --git a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php index 5d7a2369c2..68e9587648 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php @@ -148,7 +148,7 @@ class CachePoolPass implements CompilerPassInterface } } - private function getNamespace($seed, $id) + private function getNamespace(string $seed, string $id) { return substr(str_replace('/', '-', base64_encode(hash('sha256', $id.$seed, true))), 0, 10); } diff --git a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php index 9c1ef46015..328971953f 100644 --- a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php @@ -92,7 +92,7 @@ class DefaultMarshaller implements MarshallerInterface /** * @internal */ - public static function handleUnserializeCallback($class) + public static function handleUnserializeCallback(string $class) { throw new \DomainException('Class not found: '.$class); } diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index c11f53257a..1291acfae3 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -61,7 +61,7 @@ trait AbstractAdapterTrait * * @return bool True if item exists in the cache, false otherwise */ - abstract protected function doHave($id); + abstract protected function doHave(string $id); /** * Deletes all items in the pool. @@ -70,7 +70,7 @@ trait AbstractAdapterTrait * * @return bool True if the pool was successfully cleared, false otherwise */ - abstract protected function doClear($namespace); + abstract protected function doClear(string $namespace); /** * Removes multiple items from the pool. @@ -89,7 +89,7 @@ trait AbstractAdapterTrait * * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not */ - abstract protected function doSave(array $values, $lifetime); + abstract protected function doSave(array $values, int $lifetime); /** * {@inheritdoc} diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index 37e1fd1f06..2f953a89c4 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -51,7 +51,7 @@ trait FilesystemCommonTrait /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { $ok = true; diff --git a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php index 9c444f9b04..90c2f2e442 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php @@ -91,7 +91,7 @@ trait FilesystemTrait /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { $expiresAt = $lifetime ? (time() + $lifetime) : 0; $values = $this->marshaller->marshall($values, $failed); diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 6f6d94bbe8..46f3ddd736 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -332,7 +332,7 @@ trait RedisTrait /** * {@inheritdoc} */ - protected function doClear($namespace) + protected function doClear(string $namespace) { $cleared = true; if ($this->redis instanceof \Predis\Client) { @@ -399,7 +399,7 @@ trait RedisTrait /** * {@inheritdoc} */ - protected function doSave(array $values, $lifetime) + protected function doSave(array $values, int $lifetime) { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed;