Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] finish type-hints #32298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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
Copy link
Contributor Author

@Tobion Tobion Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent has an int $lifetime and it does not seem to ever be called with null as lifetime. Also current implementation would be broken with null because two lines below it calls $this->doSaveCache($values, $lifetime); which requires an int as lifetime.

{
$failed = $this->doSaveCache($values, $lifetime);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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