Skip to content

Commit

Permalink
Merge pull request #310 from boesing/qa/enhance-type-strictness
Browse files Browse the repository at this point in the history
Enhance type strictness and add `final` to a bunch of classes
  • Loading branch information
boesing authored Jun 14, 2024
2 parents a19649d + 04c3b2d commit 53a6e0e
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 35 deletions.
11 changes: 4 additions & 7 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

final class Module
{
/**
* Return default laminas-cache configuration for laminas-mvc context.
*/
public function getConfig(): array
{
$provider = new ConfigProvider();
return [
'service_manager' => $provider->getDependencyConfig(),
];
$config = (new ConfigProvider())();
$config['service_manager'] = $config['dependencies'];
unset($config['dependencies']);
return $config;
}
}
2 changes: 1 addition & 1 deletion src/Pattern/CallbackCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function serialize;
use function strtolower;

class CallbackCache extends AbstractStorageCapablePattern
final class CallbackCache extends AbstractStorageCapablePattern
{
/**
* Call the specified callback or get the result from cache
Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/CaptureCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use const DIRECTORY_SEPARATOR;
use const LOCK_EX;

class CaptureCache extends AbstractPattern
final class CaptureCache extends AbstractPattern
{
public function start(string|null $pageId = null): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/ObjectCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function sprintf;
use function strtolower;

class ObjectCache extends AbstractStorageCapablePattern implements Stringable
final class ObjectCache extends AbstractStorageCapablePattern implements Stringable
{
private CallbackCache $callbackCache;

Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/OutputCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use function ob_implicit_flush;
use function ob_start;

class OutputCache extends AbstractStorageCapablePattern
final class OutputCache extends AbstractStorageCapablePattern
{
/**
* The key stack
Expand Down
6 changes: 3 additions & 3 deletions src/Psr/CacheItemPool/CacheItemPoolDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache.md
* @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache-meta.md
*/
class CacheItemPoolDecorator implements CacheItemPoolInterface
final class CacheItemPoolDecorator implements CacheItemPoolInterface
{
use MaximumKeyLengthTrait;
use SerializationTrait;
Expand Down Expand Up @@ -373,8 +373,8 @@ private function validateKeys(array $keys): void
}

/**
* @psalm-param non-empty-list<CacheItem> $items
* @psalm-return array<string,CacheItem>
* @param non-empty-list<CacheItem> $items
* @return array<string,CacheItem>
*/
private function saveMultipleItems(array $items, ?int $itemTtl): array
{
Expand Down
7 changes: 2 additions & 5 deletions src/Psr/MaximumKeyLengthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ trait MaximumKeyLengthTrait
*/
public static $pcreMaximumQuantifierLength = 65535;

/**
* @var int
* @psalm-var 0|positive-int
*/
private $maximumKeyLength;
/** @var int<0,max> */
private int $maximumKeyLength;

private function memoizeMaximumKeyLengthCapability(StorageInterface $storage, Capabilities $capabilities): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/Psr/SimpleCache/SimpleCacheDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* Decorate a laminas-cache storage adapter for usage as a PSR-16 implementation.
*/
class SimpleCacheDecorator implements SimpleCacheInterface
final class SimpleCacheDecorator implements SimpleCacheInterface
{
use MaximumKeyLengthTrait;
use SerializationTrait;
Expand Down Expand Up @@ -385,7 +385,7 @@ private function convertTtlToInteger(int|DateInterval|null $ttl): int|null
}

/**
* @psalm-return list<non-empty-string>
* @return list<non-empty-string>
* @throws SimpleCacheInvalidArgumentException For invalid $iterable values.
*/
private function convertIterableKeysToList(iterable $keys): array
Expand Down
4 changes: 2 additions & 2 deletions src/Service/StorageAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function assertValidConfigurationStructure(array $configuration): void
}

/**
* @psalm-param non-empty-string $adapter
* @psalm-param list<mixed> $plugins
* @param non-empty-string $adapter
* @param list<mixed> $plugins
* @psalm-assert list<PluginArrayConfigurationWithPriorityType> $plugins
*/
private function assertValidPluginConfigurationStructure(string $adapter, array $plugins): void
Expand Down
6 changes: 3 additions & 3 deletions src/Service/StorageAdapterFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
interface StorageAdapterFactoryInterface
{
/**
* @psalm-param StorageAdapterArrayConfigurationType $configuration
* @param StorageAdapterArrayConfigurationType $configuration
*/
public function createFromArrayConfiguration(array $configuration): StorageInterface;

/**
* @psalm-param non-empty-string $storage
* @param non-empty-string $storage
* @param array<string,mixed> $options
* @psalm-param list<PluginArrayConfigurationWithPriorityType> $plugins
* @param list<PluginArrayConfigurationWithPriorityType> $plugins
*/
public function create(string $storage, array $options = [], array $plugins = []): StorageInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Service/StoragePluginFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
interface StoragePluginFactoryInterface
{
/**
* @psalm-param PluginArrayConfigurationType $configuration
* @param PluginArrayConfigurationType $configuration
*/
public function createFromArrayConfiguration(array $configuration): PluginInterface;

Expand Down
5 changes: 1 addition & 4 deletions src/Storage/Adapter/KeyListIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
use Countable;
use Laminas\Cache\Storage\IteratorInterface;
use Laminas\Cache\Storage\StorageInterface;
use ReturnTypeWillChange;

use function count;

/**
* @see ReturnTypeWillChange
*
* @template-covariant TValue
* @template-implements IteratorInterface<non-empty-string, TValue>
*/
class KeyListIterator implements IteratorInterface, Countable
final class KeyListIterator implements IteratorInterface, Countable
{
/**
* The iterator mode
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Plugin/ClearExpiredByFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use function random_int;

class ClearExpiredByFactor extends AbstractPlugin
final class ClearExpiredByFactor extends AbstractPlugin
{
/**
* {@inheritDoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Plugin/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use function call_user_func;

class ExceptionHandler extends AbstractPlugin
final class ExceptionHandler extends AbstractPlugin
{
/**
* {@inheritDoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Plugin/IgnoreUserAbort.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use function connection_aborted;
use function ignore_user_abort;

class IgnoreUserAbort extends AbstractPlugin
final class IgnoreUserAbort extends AbstractPlugin
{
/**
* The storage who activated ignore_user_abort.
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Plugin/OptimizeByFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use function random_int;

class OptimizeByFactor extends AbstractPlugin
final class OptimizeByFactor extends AbstractPlugin
{
/**
* {@inheritDoc}
Expand Down

0 comments on commit 53a6e0e

Please sign in to comment.