Skip to content

Commit

Permalink
Merge pull request #319 from boesing/bugfix/add-missing-template-type…
Browse files Browse the repository at this point in the history
…-storageinterface

Add missing template param for `StorageInterface`
  • Loading branch information
boesing authored Jun 21, 2024
2 parents 512dc92 + 2cd2b28 commit 03b73c8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Storage/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

/**
* @template TOptions of AdapterOptions
* @template-implements StorageInterface<TOptions>
*/
abstract class AbstractAdapter implements StorageInterface, PluginAwareInterface
{
Expand Down
11 changes: 8 additions & 3 deletions src/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
namespace Laminas\Cache\Storage;

use Laminas\Cache\Exception\ExceptionInterface;
use Laminas\Cache\Storage\Adapter\AdapterOptions;

/**
* NOTE: when providing integrish cache keys in iterables, internal array conversion might convert these to int, even
* NOTE: when providing integerish cache keys in iterables, internal array conversion might convert these to int, even
* tho they were non-empty-string beforehand. See https://3v4l.org/GsiBl for more details.
*
* @psalm-type CacheKeyInIterableType = non-empty-string|int
* @template TOptions of AdapterOptions
*/
interface StorageInterface
{
public function setOptions(iterable|Adapter\AdapterOptions $options): self;
public function setOptions(iterable|AdapterOptions $options): self;

public function getOptions(): Adapter\AdapterOptions;
/**
* @return TOptions
*/
public function getOptions(): AdapterOptions;

/* reading */
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

namespace LaminasTest\Cache\Psr\CacheItemPool\TestAsset;

use Laminas\Cache\Storage\Adapter\AdapterOptions;
use Laminas\Cache\Storage\FlushableInterface;
use Laminas\Cache\Storage\StorageInterface;

/**
* @template TOptions of AdapterOptions
* @template-extends StorageInterface<TOptions>
*/
interface FlushableStorageAdapterInterface extends StorageInterface, FlushableInterface
{
}
5 changes: 5 additions & 0 deletions test/Psr/TestAsset/FlushableNamespaceStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

namespace LaminasTest\Cache\Psr\TestAsset;

use Laminas\Cache\Storage\Adapter\AdapterOptions;
use Laminas\Cache\Storage\ClearByNamespaceInterface;

/**
* @template TOptions of AdapterOptions
* @template-extends FlushableStorageInterface<TOptions>
*/
interface FlushableNamespaceStorageInterface extends FlushableStorageInterface, ClearByNamespaceInterface
{
}
5 changes: 5 additions & 0 deletions test/Psr/TestAsset/FlushableStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

namespace LaminasTest\Cache\Psr\TestAsset;

use Laminas\Cache\Storage\Adapter\AdapterOptions;
use Laminas\Cache\Storage\FlushableInterface;
use Laminas\Cache\Storage\PluginAwareInterface;
use Laminas\Cache\Storage\StorageInterface;

/**
* @template TOptions of AdapterOptions
* @template-extends StorageInterface<TOptions>
*/
interface FlushableStorageInterface extends StorageInterface, FlushableInterface, PluginAwareInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

namespace LaminasTest\Cache\Storage\Adapter\TestAsset;

use Laminas\Cache\Storage\Adapter\AdapterOptions;
use Laminas\Cache\Storage\Plugin\PluginInterface;
use Laminas\Cache\Storage\StorageInterface;
use Laminas\EventManager\EventsCapableInterface;

/**
* @template TOptions of AdapterOptions
* @template-extends StorageInterface<TOptions>
*/
interface AdapterWithStorageAndEventsCapableInterface extends StorageInterface, EventsCapableInterface
{
public function hasPlugin(PluginInterface $plugin): bool;
Expand Down

0 comments on commit 03b73c8

Please sign in to comment.