Skip to content

Commit

Permalink
Merge pull request #24 from navarr/return-types
Browse files Browse the repository at this point in the history
Add Parameter & Return Types (versions 3 of the library)
  • Loading branch information
Jean85 committed Oct 29, 2021
2 parents 8707bf3 + 19a4d7c commit 764e0b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -19,7 +19,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
}
16 changes: 8 additions & 8 deletions src/CacheInterface.php
Expand Up @@ -15,7 +15,7 @@ interface CacheInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function get(string $key, mixed $default = null);
public function get(string $key, mixed $default = null): mixed;

/**
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
Expand All @@ -31,7 +31,7 @@ public function get(string $key, mixed $default = null);
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null);
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool;

/**
* Delete an item from the cache by its unique key.
Expand All @@ -43,14 +43,14 @@ public function set(string $key, mixed $value, null|int|\DateInterval $ttl = nul
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function delete(string $key);
public function delete(string $key): bool;

/**
* Wipes clean the entire cache's keys.
*
* @return bool True on success and false on failure.
*/
public function clear();
public function clear(): bool;

/**
* Obtains multiple cache items by their unique keys.
Expand All @@ -64,7 +64,7 @@ public function clear();
* MUST be thrown if $keys is neither an array nor a Traversable,
* or if any of the $keys are not a legal value.
*/
public function getMultiple(iterable $keys, mixed $default = null);
public function getMultiple(iterable $keys, mixed $default = null): iterable;

/**
* Persists a set of key => value pairs in the cache, with an optional TTL.
Expand All @@ -80,7 +80,7 @@ public function getMultiple(iterable $keys, mixed $default = null);
* MUST be thrown if $values is neither an array nor a Traversable,
* or if any of the $values are not a legal value.
*/
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null);
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool;

/**
* Deletes multiple cache items in a single operation.
Expand All @@ -93,7 +93,7 @@ public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null
* MUST be thrown if $keys is neither an array nor a Traversable,
* or if any of the $keys are not a legal value.
*/
public function deleteMultiple(iterable $keys);
public function deleteMultiple(iterable $keys): bool;

/**
* Determines whether an item is present in the cache.
Expand All @@ -110,5 +110,5 @@ public function deleteMultiple(iterable $keys);
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function has(string $key);
public function has(string $key): bool;
}

0 comments on commit 764e0b3

Please sign in to comment.