Skip to content

Commit

Permalink
Merge pull request #101 from YerToffeeRoll/master
Browse files Browse the repository at this point in the history
Update the Cache classes NullAdapter.php/NullCacheItem.php to use str…
  • Loading branch information
georged authored Dec 14, 2023
2 parents e15a16d + a4a5c34 commit b102b1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/Cache/NullAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NullAdapter implements CacheItemPoolInterface {
* @return CacheItemInterface
* The corresponding Cache Item.
*/
public function getItem( $key ) {
public function getItem(string $key) : CacheItemInterface {
return new NullCacheItem( $key );
}

Expand All @@ -65,7 +65,7 @@ public function getItem( $key ) {
* key is not found. However, if no keys are specified then an empty
* traversable MUST be returned instead.
*/
public function getItems( array $keys = [] ) {
public function getItems( array $keys = [] ) : iterable {
$items = [];
foreach ( $keys as $key ) {
$items[] = new NullCacheItem( $key );
Expand All @@ -91,7 +91,7 @@ public function getItems( array $keys = [] ) {
* @return bool
* True if item exists in the cache, false otherwise.
*/
public function hasItem( $key ) {
public function hasItem( $key ) : bool {
return false;
}

Expand All @@ -101,7 +101,7 @@ public function hasItem( $key ) {
* @return bool
* True if the pool was successfully cleared. False if there was an error.
*/
public function clear() {
public function clear() : bool {
return true;
}

Expand All @@ -118,7 +118,7 @@ public function clear() {
* @return bool
* True if the item was successfully removed. False if there was an error.
*/
public function deleteItem( $key ) {
public function deleteItem( $key ) : bool {
return true;
}

Expand All @@ -135,7 +135,7 @@ public function deleteItem( $key ) {
* @return bool
* True if the items were successfully removed. False if there was an error.
*/
public function deleteItems( array $keys ) {
public function deleteItems( array $keys ) : bool {
return true;
}

Expand All @@ -148,7 +148,7 @@ public function deleteItems( array $keys ) {
* @return bool
* True if the item was successfully persisted. False if there was an error.
*/
public function save( CacheItemInterface $item ) {
public function save( CacheItemInterface $item ) : bool {
return true;
}

Expand All @@ -161,7 +161,7 @@ public function save( CacheItemInterface $item ) {
* @return bool
* False if the item could not be queued or if a commit was attempted and failed. True otherwise.
*/
public function saveDeferred( CacheItemInterface $item ) {
public function saveDeferred( CacheItemInterface $item ) : bool {
return true;
}

Expand All @@ -171,7 +171,7 @@ public function saveDeferred( CacheItemInterface $item ) {
* @return bool
* True if all not-yet-saved items were successfully saved or there were none. False otherwise.
*/
public function commit() {
public function commit() : bool {
return true;
}

Expand Down
15 changes: 8 additions & 7 deletions src/Cache/NullCacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace AlexaCRM\Cache;

use Psr\Cache\CacheItemInterface;
use DateTimeInterface;

/**
* Represents a PSR-6 compliant dummy cache item.
Expand All @@ -37,7 +38,7 @@ class NullCacheItem implements CacheItemInterface {
*
* @param string $key
*/
public function __construct( $key ) {
public function __construct( $key ) {
$this->key = $key;
}

Expand All @@ -50,7 +51,7 @@ public function __construct( $key ) {
* @return string
* The key string for this cache item.
*/
public function getKey() {
public function getKey() : string {
return $this->key;
}

Expand All @@ -66,7 +67,7 @@ public function getKey() {
* @return mixed
* The value corresponding to this cache item's key, or null if not found.
*/
public function get() {
public function get() : bool {
return null;
}

Expand All @@ -79,7 +80,7 @@ public function get() {
* @return bool
* True if the request resulted in a cache hit. False otherwise.
*/
public function isHit() {
public function isHit() : bool {
return false;
}

Expand All @@ -96,7 +97,7 @@ public function isHit() {
* @return static
* The invoked object.
*/
public function set( $value ) {
public function set(mixed $value ) : static {
return $this;
}

Expand All @@ -112,7 +113,7 @@ public function set( $value ) {
* @return static
* The called object.
*/
public function expiresAt( $expiration ) {
public function expiresAt(?DateTimeInterface $expiration): static {
return $this;
}

Expand All @@ -129,7 +130,7 @@ public function expiresAt( $expiration ) {
* @return static
* The called object.
*/
public function expiresAfter( $time ) {
public function expiresAfter(int|\DateInterval|null $time): static {
return $this;
}
}

0 comments on commit b102b1f

Please sign in to comment.