diff --git a/composer.json b/composer.json index e8b4006..6c1296f 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require": { "php": ">= 8", "ext-json": "*", - "predis/predis": "^1.1", + "predis/predis": "^1.1.10", "psr/log": "*", "psr/cache": "^3.0.0", "psr/simple-cache": "^3.0.0" @@ -36,15 +36,15 @@ "require-dev": { "ext-apcu": "*", "ext-memcached": "*", - "consolidation/robo": "^3.0.6", - "monolog/monolog": "^2.3.5", - "pdepend/pdepend": "^2.2", - "phploc/phploc": "^7.0", - "phpmd/phpmd": "^2.4", - "phpunit/phpunit": "^9.5.0", + "consolidation/robo": "^3.0.11", + "monolog/monolog": "^2.8.0", + "pdepend/pdepend": "^2.12.1", + "phploc/phploc": "^7.0.2", + "phpmd/phpmd": "^2.13", + "phpunit/phpunit": "^9.6.0", "sebastian/phpcpd": "^6.0.3", - "squizlabs/php_codesniffer": "^3.3.2", - "phpstan/phpstan": "^1.2.0" + "squizlabs/php_codesniffer": "^3.7.1", + "phpstan/phpstan": "^1.9.14" }, "suggest": { "monolog/monolog": "A good standard logging library", diff --git a/src/Driver/MemcachedDriver.php b/src/Driver/MemcachedDriver.php index e6fd11a..d98f5b6 100644 --- a/src/Driver/MemcachedDriver.php +++ b/src/Driver/MemcachedDriver.php @@ -28,7 +28,7 @@ use MemcachedException; class MemcachedDriver extends AbstractDriver { /** - * @var Memcached + * The Memcached connection */ private Memcached $conn; @@ -184,7 +184,6 @@ class MemcachedDriver extends AbstractDriver { $deleted = $this->conn->deleteMulti($keys); - // @phpstan-ignore-next-line if (is_array($deleted)) { foreach ($deleted as $key => $status) @@ -197,8 +196,6 @@ class MemcachedDriver extends AbstractDriver { return TRUE; } - - return FALSE; } /** diff --git a/src/Item.php b/src/Item.php index 04fda48..2f496e8 100644 --- a/src/Item.php +++ b/src/Item.php @@ -59,7 +59,7 @@ class Item implements CacheItemInterface { * * @var mixed */ - protected $value; + protected mixed $value = null; /** * Create a Cache Item object @@ -157,7 +157,7 @@ class Item implements CacheItemInterface { * @return static * The called object. */ - public function expiresAt($expiration = NULL): static + public function expiresAt(DateTimeInterface $expiration = NULL): static { if ($expiration instanceof DateTimeInterface) { @@ -172,7 +172,7 @@ class Item implements CacheItemInterface { /** * Sets the expiration time for this cache item. * - * @param int|DateInterval|null $time + * @param DateInterval|int|null $time * The period of time from the present after which the item MUST be considered * expired. An integer parameter is understood to be the time in seconds until * expiration. If null is passed explicitly, a default value MAY be used. @@ -182,7 +182,7 @@ class Item implements CacheItemInterface { * @return static * The called object. */ - public function expiresAfter($time = NULL): static + public function expiresAfter(DateInterval|int $time = NULL): static { if ($time instanceof DateInterval) { diff --git a/src/ItemCollection.php b/src/ItemCollection.php index 673d50f..4dda120 100644 --- a/src/ItemCollection.php +++ b/src/ItemCollection.php @@ -42,7 +42,7 @@ class ItemCollection extends ArrayIterator implements JsonSerializable { * @param array $items - array of CacheItemInterface objects * @param int $flags - flags */ - public function __construct(array $items = [], $flags = 0) + public function __construct(array $items = [], int $flags = 0) { parent::__construct($items, $flags); $this->items = $items; diff --git a/src/LoggerTrait.php b/src/LoggerTrait.php index cccbdc8..a5c5b9e 100644 --- a/src/LoggerTrait.php +++ b/src/LoggerTrait.php @@ -32,8 +32,6 @@ trait LoggerTrait { /** * Return the existing logger instance or * a NullLogger, if no instance set - * - * @return LoggerInterface */ protected function getLogger(): LoggerInterface { @@ -46,9 +44,6 @@ trait LoggerTrait { /** * Set a logger to keep track of errors - * - * @param LoggerInterface $logger - * @return self */ public function setLogger(LoggerInterface $logger): self { diff --git a/src/_Driver.php b/src/_Driver.php index d4f9b87..3767b89 100644 --- a/src/_Driver.php +++ b/src/_Driver.php @@ -39,7 +39,7 @@ trait _Driver { protected function loadDriver(array $driverConfig = []): AbstractDriver { $driver = ucfirst(strtolower($driverConfig['driver'] ?? 'null')); - $class = __NAMESPACE__ . "\\Driver\\${driver}Driver"; + $class = __NAMESPACE__ . "\\Driver\\{$driver}Driver"; $driverConfig['connection'] = $driverConfig['connection'] ?? []; $driverConfig['options'] = $driverConfig['options'] ?? []; diff --git a/tests/ItemTest.php b/tests/ItemTest.php index ed58ec0..daa8f3f 100644 --- a/tests/ItemTest.php +++ b/tests/ItemTest.php @@ -60,10 +60,11 @@ class ItemTest extends TestCase { $friend = new Friend($this->item); $this->assertEquals($expected, $friend->expiresAt, "DateTimeInterface"); - $time2 = strtotime("July 16, 2024"); + $time2stamp = strtotime("July 16, 2024"); + $time2 = new DateTime("July 16, 2024"); $this->item->expiresAt($time2); $friend2 = new Friend($this->item); - $this->assertEquals($time2, $friend2->expiresAt, "Unix Timestamp"); + $this->assertEquals($time2stamp, $friend2->expiresAt, "Unix Timestamp"); } public function testExpiresAfter(): void