Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing template param for StorageInterface #319

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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