Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 13769aa

Browse files
jack-wormannicolas-grekas
authored andcommitted
Add cache contracts template annotations
1 parent 41fb28e commit 13769aa

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

‎CacheInterface.php‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ interface CacheInterface
2929
* requested key, that could be used e.g. for expiration control. It could also
3030
* be an ItemInterface instance when its additional features are needed.
3131
*
32-
* @param string $key The key of the item to retrieve from the cache
33-
* @param callable|CallbackInterface $callback Should return the computed value for the given key/item
34-
* @param float|null $beta A float that, as it grows, controls the likeliness of triggering
35-
* early expiration. 0 disables it, INF forces immediate expiration.
36-
* The default (or providing null) is implementation dependent but should
37-
* typically be 1.0, which should provide optimal stampede protection.
38-
* See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration
39-
* @param array &$metadata The metadata of the cached item {@see ItemInterface::getMetadata()}
32+
* @template T
33+
*
34+
* @param string $key The key of the item to retrieve from the cache
35+
* @param (callable(CacheItemInterface,bool):T)|(callable(ItemInterface,bool):T)|CallbackInterface<T> $callback
36+
* @param float|null $beta A float that, as it grows, controls the likeliness of triggering
37+
* early expiration. 0 disables it, INF forces immediate expiration.
38+
* The default (or providing null) is implementation dependent but should
39+
* typically be 1.0, which should provide optimal stampede protection.
40+
* See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration
41+
* @param array &$metadata The metadata of the cached item {@see ItemInterface::getMetadata()}
42+
*
43+
* @return T
4044
*
4145
* @throws InvalidArgumentException When $key is not valid or when $beta is negative
4246
*/

‎CallbackInterface.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
* Computes and returns the cached value of an item.
1818
*
1919
* @author Nicolas Grekas <p@tchwork.com>
20+
*
21+
* @template T
2022
*/
2123
interface CallbackInterface
2224
{
2325
/**
2426
* @param CacheItemInterface|ItemInterface $item The item to compute the value for
2527
* @param bool &$save Should be set to false when the value should not be saved in the pool
2628
*
27-
* @return mixed The computed value for the passed item
29+
* @return T The computed value for the passed item
2830
*/
2931
public function __invoke(CacheItemInterface $item, bool &$save): mixed;
3032
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /