Skip to content

Commit 47b1bbc

Browse files
committed
Add generics to cache item
1 parent a535924 commit 47b1bbc

6 files changed

+59
-1
lines changed

extension.neon

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ parameters:
1313
consoleApplicationLoader: null
1414
stubFiles:
1515
- stubs/Psr/Cache/CacheItemInterface.stub
16+
- stubs/Psr/Cache/CacheItemPoolInterface.stub
1617
- stubs/Symfony/Bundle/FrameworkBundle/KernelBrowser.stub
1718
- stubs/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.stub
1819
- stubs/Symfony/Bundle/FrameworkBundle/Test/TestContainer.stub

stubs/Psr/Cache/CacheItemInterface.stub

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
namespace Psr\Cache;
44

5+
/**
6+
* @template TValue
7+
*/
58
interface CacheItemInterface
69
{
10+
/**
11+
* @return TValue
12+
*/
13+
public function get();
14+
15+
/**
16+
* @param TValue $value
17+
*
18+
* @return static
19+
*/
20+
public function set($value);
721
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Psr\Cache;
4+
5+
/**
6+
* @template TValue
7+
*/
8+
interface CacheItemPoolInterface
9+
{
10+
/**
11+
* @param string $key
12+
*
13+
* @return CacheItemInterface<TValue>
14+
*/
15+
public function getItem($key);
16+
17+
/**
18+
* @param array<string> $keys
19+
*
20+
* @return array<CacheItemInterface<TValue>>|\Traversable<CacheItemInterface<TValue>>
21+
*/
22+
public function getItems(array $keys = array());
23+
24+
/**
25+
* @param CacheItemInterface<TValue> $item
26+
*
27+
* @return bool
28+
*/
29+
public function save(CacheItemInterface $item);
30+
31+
/**
32+
* @param CacheItemInterface<TValue> $item
33+
*
34+
* @return bool
35+
*/
36+
public function saveDeferred(CacheItemInterface $item);
37+
}

stubs/Symfony/Contracts/Cache/CacheInterface.stub

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface CacheInterface
77
/**
88
* @template T
99
*
10-
* @param \Symfony\Contracts\Cache\CallbackInterface<T>|callable(\Symfony\Contracts\Cache\ItemInterface, bool): T $callback
10+
* @param \Symfony\Contracts\Cache\CallbackInterface<T>|callable(\Symfony\Contracts\Cache\ItemInterface<T>, bool): T $callback
1111
* @param array<mixed> $metadata
1212
* @return T
1313
*/

stubs/Symfony/Contracts/Cache/CallbackInterface.stub

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use Psr\Cache\CacheItemInterface;
1010
interface CallbackInterface
1111
{
1212
/**
13+
* @param CacheItemInterface<T> $item
14+
*
1315
* @return T
1416
*/
1517
public function __invoke(CacheItemInterface $item, bool &$save);

stubs/Symfony/Contracts/Cache/ItemInterface.stub

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ namespace Symfony\Contracts\Cache;
44

55
use Psr\Cache\CacheItemInterface;
66

7+
/**
8+
* @template TValue
9+
* @extends CacheItemInterface<TValue>
10+
*/
711
interface ItemInterface extends CacheItemInterface
812
{
913
}

0 commit comments

Comments
 (0)