Skip to content
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

Add psr/cache version 3.0 support #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"homepage": "http://www.php-cache.com/en/latest/",
"require": {
"php": ">=7.4",
"psr/cache": "^1.0 || ^2.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
Expand All @@ -35,11 +35,13 @@
"prefer-stable": true,
"autoload": {
"psr-4": {
"Cache\\Bridge\\SimpleCache\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
"Cache\\Bridge\\SimpleCache\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Cache\\Bridge\\SimpleCache\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions SimpleCacheBridge.php → src/SimpleCacheBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(CacheItemPoolInterface $cacheItemPool)
/**
* {@inheritdoc}
*/
public function get($key, $default = null)
public function get($key, mixed $default = null): mixed
{
try {
$item = $this->cacheItemPool->getItem($key);
Expand All @@ -58,7 +58,7 @@ public function get($key, $default = null)
/**
* {@inheritdoc}
*/
public function set($key, $value, $ttl = null)
public function set($key, mixed $value, null|int|\DateInterval $ttl = null): bool
{
try {
$item = $this->cacheItemPool->getItem($key);
Expand All @@ -75,7 +75,7 @@ public function set($key, $value, $ttl = null)
/**
* {@inheritdoc}
*/
public function delete($key)
public function delete(string $key): bool
{
try {
return $this->cacheItemPool->deleteItem($key);
Expand All @@ -87,15 +87,15 @@ public function delete($key)
/**
* {@inheritdoc}
*/
public function clear()
public function clear(): bool
{
return $this->cacheItemPool->clear();
}

/**
* {@inheritdoc}
*/
public function getMultiple($keys, $default = null)
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
if (!is_array($keys)) {
if (!$keys instanceof \Traversable) {
Expand All @@ -122,7 +122,7 @@ public function getMultiple($keys, $default = null)
*
* @return \Generator
*/
private function generateValues($default, $items)
private function generateValues(mixed $default, $items)
{
foreach ($items as $key => $item) {
/** @type $item CacheItemInterface */
Expand All @@ -137,7 +137,7 @@ private function generateValues($default, $items)
/**
* {@inheritdoc}
*/
public function setMultiple($values, $ttl = null)
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool
{
if (!is_array($values)) {
if (!$values instanceof \Traversable) {
Expand Down Expand Up @@ -191,7 +191,7 @@ public function setMultiple($values, $ttl = null)
/**
* {@inheritdoc}
*/
public function deleteMultiple($keys)
public function deleteMultiple(iterable $keys): bool
{
if (!is_array($keys)) {
if (!$keys instanceof \Traversable) {
Expand All @@ -213,7 +213,7 @@ public function deleteMultiple($keys)
/**
* {@inheritdoc}
*/
public function has($key)
public function has(string $key): bool
{
try {
return $this->cacheItemPool->hasItem($key);
Expand Down