Skip to content

Commit 57e012a

Browse files
committed
bugfix: add adapter options template to StorageInterface usage
Signed-off-by: Maximilian Bösing <[email protected]>
1 parent 2cd2b28 commit 57e012a

12 files changed

+44
-2
lines changed

src/Pattern/AbstractStorageCapablePattern.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@
44

55
namespace Laminas\Cache\Pattern;
66

7+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
78
use Laminas\Cache\Storage\StorageInterface;
89

910
abstract class AbstractStorageCapablePattern extends AbstractPattern implements StorageCapableInterface
1011
{
12+
/**
13+
* @param StorageInterface<AdapterOptions> $storage
14+
*/
1115
public function __construct(protected StorageInterface $storage, ?PatternOptions $options = null)
1216
{
1317
parent::__construct($options);
1418
}
1519

20+
/**
21+
* @return StorageInterface<AdapterOptions>
22+
*/
1623
public function getStorage(): StorageInterface
1724
{
1825
return $this->storage;

src/Pattern/ObjectCache.php

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laminas\Cache\Pattern;
44

55
use Laminas\Cache\Exception;
6+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
67
use Laminas\Cache\Storage\StorageInterface;
78
use Stringable;
89
use Throwable;
@@ -21,6 +22,9 @@ final class ObjectCache extends AbstractStorageCapablePattern implements Stringa
2122
{
2223
private CallbackCache $callbackCache;
2324

25+
/**
26+
* @param StorageInterface<AdapterOptions> $storage
27+
*/
2428
public function __construct(StorageInterface $storage, ?PatternOptions $options = null)
2529
{
2630
parent::__construct($storage, $options);

src/Psr/CacheItemPool/CacheItemPoolDecorator.php

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Laminas\Cache\Psr\Clock;
88
use Laminas\Cache\Psr\MaximumKeyLengthTrait;
99
use Laminas\Cache\Psr\SerializationTrait;
10+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
1011
use Laminas\Cache\Storage\ClearByNamespaceInterface;
1112
use Laminas\Cache\Storage\FlushableInterface;
1213
use Laminas\Cache\Storage\StorageInterface;
@@ -292,6 +293,7 @@ public function commit(): bool
292293
/**
293294
* Throws exception is storage is not compatible with PSR-6
294295
*
296+
* @param StorageInterface<AdapterOptions> $storage
295297
* @throws CacheException
296298
*/
297299
private function validateStorage(StorageInterface $storage): void

src/Psr/MaximumKeyLengthTrait.php

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Laminas\Cache\Psr;
66

77
use Laminas\Cache\Psr\SimpleCache\SimpleCacheInvalidArgumentException;
8+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
89
use Laminas\Cache\Storage\Capabilities;
910
use Laminas\Cache\Storage\StorageInterface;
1011

@@ -32,6 +33,9 @@ trait MaximumKeyLengthTrait
3233
/** @var int<0,max> */
3334
private int $maximumKeyLength;
3435

36+
/**
37+
* @param StorageInterface<AdapterOptions> $storage
38+
*/
3539
private function memoizeMaximumKeyLengthCapability(StorageInterface $storage, Capabilities $capabilities): void
3640
{
3741
$maximumKeyLength = $capabilities->maxKeyLength;

src/Psr/SerializationTrait.php

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Laminas\Cache\Psr;
44

5+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
56
use Laminas\Cache\Storage\StorageInterface;
67

78
use function in_array;
@@ -16,6 +17,8 @@ trait SerializationTrait
1617
{
1718
/**
1819
* Determine if the given storage adapter requires serialization.
20+
*
21+
* @param StorageInterface<AdapterOptions> $storage
1922
*/
2023
private function isSerializationRequired(StorageInterface $storage): bool
2124
{

src/Psr/SimpleCache/SimpleCacheDecorator.php

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Laminas\Cache\Psr\Clock;
99
use Laminas\Cache\Psr\MaximumKeyLengthTrait;
1010
use Laminas\Cache\Psr\SerializationTrait;
11+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
1112
use Laminas\Cache\Storage\Capabilities;
1213
use Laminas\Cache\Storage\ClearByNamespaceInterface;
1314
use Laminas\Cache\Storage\FlushableInterface;
@@ -54,6 +55,9 @@ final class SimpleCacheDecorator implements SimpleCacheInterface
5455

5556
private ClockInterface $clock;
5657

58+
/**
59+
* @param StorageInterface<AdapterOptions> $storage
60+
*/
5761
public function __construct(
5862
private readonly StorageInterface $storage,
5963
?ClockInterface $clock = null,

src/Storage/Adapter/AdapterOptions.php

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class AdapterOptions extends AbstractOptions
4646

4747
/**
4848
* The adapter using these options
49+
*
50+
* @var StorageInterface<AdapterOptions>
4951
*/
5052
protected ?StorageInterface $adapter = null;
5153

@@ -78,6 +80,8 @@ class AdapterOptions extends AbstractOptions
7880

7981
/**
8082
* Adapter using this instance
83+
*
84+
* @param StorageInterface<AdapterOptions> $adapter
8185
*/
8286
public function setAdapter(?StorageInterface $adapter = null): self
8387
{

src/Storage/Adapter/KeyListIterator.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ final class KeyListIterator implements IteratorInterface, Countable
3232
protected int $position = 0;
3333

3434
/**
35+
* @param StorageInterface<AdapterOptions> $storage
3536
* @param array<int,non-empty-string> $keys Keys to iterate over
3637
*/
3738
public function __construct(
@@ -42,7 +43,7 @@ public function __construct(
4243
}
4344

4445
/**
45-
* Get storage instance
46+
* @return StorageInterface<AdapterOptions>
4647
*/
4748
public function getStorage(): StorageInterface
4849
{

src/Storage/Event.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laminas\Cache\Storage;
44

55
use ArrayObject;
6+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
67
use Laminas\EventManager\Event as BaseEvent;
78

89
/** @extends BaseEvent<StorageInterface, ArrayObject> */
@@ -12,6 +13,7 @@ class Event extends BaseEvent
1213
* Accept a storage adapter and its parameters.
1314
*
1415
* @param non-empty-string $name Event name
16+
* @param StorageInterface<AdapterOptions> $storage
1517
* @param ArrayObject<string,mixed> $params
1618
*/
1719
public function __construct(string $name, StorageInterface $storage, ArrayObject $params)
@@ -24,7 +26,7 @@ public function __construct(string $name, StorageInterface $storage, ArrayObject
2426
*
2527
* @see \Laminas\EventManager\Event::setTarget()
2628
*
27-
* @param StorageInterface $target
29+
* @param StorageInterface<AdapterOptions> $target
2830
*/
2931
public function setTarget($target): void
3032
{
@@ -36,6 +38,8 @@ public function setTarget($target): void
3638
* Alias of setTarget
3739
*
3840
* @see \Laminas\EventManager\Event::setTarget()
41+
*
42+
* @param StorageInterface<AdapterOptions> $storage
3943
*/
4044
public function setStorage(StorageInterface $storage): self
4145
{
@@ -45,6 +49,8 @@ public function setStorage(StorageInterface $storage): self
4549

4650
/**
4751
* Alias of getTarget
52+
*
53+
* @return StorageInterface<AdapterOptions>
4854
*/
4955
public function getStorage(): StorageInterface
5056
{

src/Storage/ExceptionEvent.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laminas\Cache\Storage;
44

55
use ArrayObject;
6+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
67
use Throwable;
78

89
class ExceptionEvent extends PostEvent
@@ -21,6 +22,7 @@ class ExceptionEvent extends PostEvent
2122
* Accept a target and its parameters.
2223
*
2324
* @param non-empty-string $name Event name
25+
* @param StorageInterface<AdapterOptions> $storage
2426
* @param ArrayObject<string,mixed> $params
2527
*/
2628
public function __construct(

src/Storage/Plugin/IgnoreUserAbort.php

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Laminas\Cache\Storage\Plugin;
44

5+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
56
use Laminas\Cache\Storage\Event;
67
use Laminas\Cache\Storage\StorageInterface;
78
use Laminas\EventManager\EventManagerInterface;
@@ -13,6 +14,8 @@ final class IgnoreUserAbort extends AbstractPlugin
1314
{
1415
/**
1516
* The storage who activated ignore_user_abort.
17+
*
18+
* @var StorageInterface<AdapterOptions>
1619
*/
1720
protected ?StorageInterface $activatedTarget = null;
1821

src/Storage/PostEvent.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laminas\Cache\Storage;
44

55
use ArrayObject;
6+
use Laminas\Cache\Storage\Adapter\AdapterOptions;
67

78
class PostEvent extends Event
89
{
@@ -15,6 +16,7 @@ class PostEvent extends Event
1516
* Accept a target and its parameters.
1617
*
1718
* @param non-empty-string $name Event name
19+
* @param StorageInterface<AdapterOptions> $storage
1820
* @param ArrayObject<string,mixed> $params
1921
*/
2022
public function __construct(string $name, StorageInterface $storage, ArrayObject $params, mixed $result)

0 commit comments

Comments
 (0)