Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNN1 committed Feb 17, 2024
1 parent 9c9f2e4 commit af03175
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5"
"phpunit/phpunit": "^11.0"
},
"suggest": {
"ext-apcu": "Required to use the APCu cache driver.",
Expand Down
6 changes: 3 additions & 3 deletions src/Storages/FileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use RobiNN\Cache\CacheInterface;

class FileStorage implements CacheInterface {
private string $path;
private readonly string $path;

private ?string $secret;
private readonly ?string $secret;

/**
* @param array<string, mixed> $config
Expand Down Expand Up @@ -167,7 +167,7 @@ private function isExpired(string $key): bool {
$expired = time() - (int) $data['time'] > (int) $data['expire'];
}

if ($expired === true) {
if ($expired) {
$this->delete($key);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Storages/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use RobiNN\Cache\CacheInterface;

class RedisStorage implements CacheInterface {
private Redis $redis;
private readonly Redis $redis;

private bool $connection = true;

Expand Down
20 changes: 8 additions & 12 deletions tests/CacheTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace RobiNN\Cache\Tests;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use RobiNN\Cache\Cache;
Expand All @@ -32,18 +33,13 @@ public function testSetterGetter(): void {
$this->cache->delete($key);
}

/**
* @return array<int, mixed>
*/
public static function keysProvider(): array {
return [
['string', 'Cache'],
['int', 23],
['float', 23.99],
['bool', true],
['null', null],
['array', ['key1', 'key2']],
];
public static function keysProvider(): Iterator {
yield ['string', 'Cache'];
yield ['int', 23];
yield ['float', 23.99];
yield ['bool', true];
yield ['null', null];
yield ['array', ['key1', 'key2']];
}

#[DataProvider('keysProvider')]
Expand Down

0 comments on commit af03175

Please sign in to comment.