Skip to content
Permalink
Browse files

minor #32298 [Cache] finish type-hints (Tobion)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Cache] finish type-hints

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #32179
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Finish leftovers from #32282

Commits
-------

1919c7d [Cache] finish type-hints
  • Loading branch information...
Tobion committed Jul 2, 2019
2 parents 0541034 + 1919c7d commit f800d01ff7ceb977b31dabc8ad3d22a8d3826886
@@ -99,12 +99,6 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
*
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
*
* @param string $namespace
* @param int $defaultLifetime
* @param string $version
* @param string $directory
* @param LoggerInterface|null $logger
*
* @return AdapterInterface
*/
public static function createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, LoggerInterface $logger = null)
@@ -128,7 +128,7 @@ static function ($deferred, &$expiredIds) use ($getId, $tagPrefix) {
*
* @return array The identifiers that failed to be cached or a boolean stating if caching succeeded or not
*/
abstract protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $removeTagData = []): array;
abstract protected function doSave(array $values, int $lifetime, array $addTagData = [], array $removeTagData = []): array;
/**
* Removes multiple items from the pool and their corresponding tags.
@@ -72,7 +72,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return apcu_exists($id);
}
@@ -31,7 +31,6 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
private $createCacheItem;
/**
* @param int $defaultLifetime
* @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise
*/
public function __construct(int $defaultLifetime = 0, bool $storeSerialized = true)
@@ -65,7 +65,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return $this->provider->contains($id);
}
@@ -51,7 +51,7 @@ public function __construct(string $namespace = '', int $defaultLifetime = 0, st
/**
* {@inheritdoc}
*/
protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $removeTagData = []): array
protected function doSave(array $values, int $lifetime, array $addTagData = [], array $removeTagData = []): array
{
$failed = $this->doSaveCache($values, $lifetime);
@@ -276,7 +276,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return false !== $this->getClient()->get(rawurlencode($id)) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode());
}
@@ -236,7 +236,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
$sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)";
$stmt = $this->getConnection()->prepare($sql);
@@ -69,7 +69,7 @@ function ($key, $value, $isHit) {
*
* @return CacheItemPoolInterface
*/
public static function create($file, CacheItemPoolInterface $fallbackPool)
public static function create(string $file, CacheItemPoolInterface $fallbackPool)
{
// Shared memory is available in PHP 7.0+ with OPCache enabled
if (filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
@@ -165,7 +165,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
if ($this->appendOnly && isset($this->values[$id])) {
return true;
@@ -55,7 +55,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return $this->pool->has($id);
}
@@ -88,7 +88,7 @@ public function __construct($redisClient, string $namespace = '', int $defaultLi
/**
* {@inheritdoc}
*/
protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $delTagData = []): array
protected function doSave(array $values, int $lifetime, array $addTagData = [], array $delTagData = []): array
{
// serialize values
if (!$serialized = $this->marshaller->marshall($values, $failed)) {
@@ -81,7 +81,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
$file = $this->getFile($id);
@@ -324,7 +324,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return (bool) $this->redis->exists($id);
}

0 comments on commit f800d01

Please sign in to comment.
You can’t perform that action at this time.