mirror of
https://github.com/danog/Valinor.git
synced 2024-11-26 20:24:40 +01:00
fix: add return types for cache implementations
Fixes the following message reported by `symfony/error-handler`: `User Deprecated: Method "Psr\SimpleCache\CacheInterface::get()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "CuyZ\Valinor\Cache\..." now to avoid errors or add an explicit @return annotation to suppress this message.`
This commit is contained in:
parent
d8957c061d
commit
0e8f12e5f7
@ -29,6 +29,11 @@ final class ChainCache implements CacheInterface
|
||||
$this->count = count($caches);
|
||||
}
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return EntryType|null
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
foreach ($this->delegates as $i => $delegate) {
|
||||
|
@ -62,6 +62,11 @@ final class CompiledPhpFileCache implements CacheInterface
|
||||
return $this->getFile($filename)->isValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return EntryType|null
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (! $this->has($key)) {
|
||||
|
@ -51,6 +51,11 @@ final class FileSystemCache implements CacheInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return EntryType|null
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
foreach ($this->delegates as $delegate) {
|
||||
|
@ -57,6 +57,11 @@ final class FileWatchingCache implements CacheInterface
|
||||
return $this->delegate->has($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return EntryType|TimestampsArray|null
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return $this->delegate->get($key, $default);
|
||||
|
@ -43,6 +43,11 @@ final class KeySanitizerCache implements CacheInterface
|
||||
$this->sanitize = static fn (string $key) => sha1("$key." . self::$version ??= PHP_VERSION . '/' . Package::version());
|
||||
}
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return EntryType|null
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return $this->delegate->get(($this->sanitize)($key), $default);
|
||||
|
@ -24,6 +24,11 @@ final class RuntimeCache implements CacheInterface
|
||||
/** @var array<string, EntryType> */
|
||||
private array $entries = [];
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return EntryType|null
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return $this->entries[$key] ?? $default;
|
||||
|
@ -44,6 +44,11 @@ final class FakeCache implements CacheInterface
|
||||
return count($this->entries);
|
||||
}
|
||||
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
$this->timesEntryWasFetched[$key] ??= 0;
|
||||
|
@ -11,6 +11,11 @@ use Psr\SimpleCache\CacheInterface;
|
||||
*/
|
||||
final class FakeFailingCache implements CacheInterface
|
||||
{
|
||||
/**
|
||||
* @PHP8.0 add `mixed` return type and remove PHPDoc
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user