Skip to content

Commit

Permalink
minor #32298 [Cache] finish type-hints (Tobion)
Browse files Browse the repository at this point in the history
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 f800d01
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 19 deletions.
6 changes: 0 additions & 6 deletions src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Expand Up @@ -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)
Expand Down
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ApcuAdapter.php
Expand Up @@ -72,7 +72,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return apcu_exists($id);
}
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php
Expand Up @@ -65,7 +65,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return $this->provider->contains($id);
}
Expand Down
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PdoAdapter.php
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/Psr16Adapter.php
Expand Up @@ -55,7 +55,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
return $this->pool->has($id);
}
Expand Down
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/FilesystemTrait.php
Expand Up @@ -81,7 +81,7 @@ protected function doFetch(array $ids)
/**
* {@inheritdoc}
*/
protected function doHave($id)
protected function doHave(string $id)
{
$file = $this->getFile($id);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/RedisTrait.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit f800d01

Please sign in to comment.