Skip to content

Commit

Permalink
Update base library to 3.0.0 (#26)
Browse files Browse the repository at this point in the history
* Update base library to 3.0.0

* Fix code style

* Fix some types

* Trigger tests for multiple versions

* Ignore php cs fixer env
  • Loading branch information
RikudouSage committed Feb 9, 2023
1 parent 5d1bbbe commit c8f3356
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ jobs:
code_style:
name: Test code style
runs-on: ubuntu-latest
env:
PHP_CS_FIXER_IGNORE_ENV: 1
strategy:
matrix:
phpVersion: ['8.0', '8.1', '8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.phpVersion }}
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
Expand All @@ -25,12 +30,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
phpVersion: ['8.0', '8.1', '8.2']
symfonyVersion: [^6.0]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.phpVersion }}
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
Expand All @@ -45,11 +51,12 @@ jobs:
strategy:
matrix:
symfonyVersion: [^6.0]
phpVersion: ['8.0', '8.1', '8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.phpVersion }}
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"symfony/framework-bundle": "^6.0",
"rikudou/psr6-dynamo-db": "^2.0",
"rikudou/psr6-dynamo-db": "^2.0 | ^3.0",
"php": "^8.0",
"symfony/cache": "^6.0",
"ext-json": "*"
Expand Down
7 changes: 5 additions & 2 deletions src/Cache/DynamoDbCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public function __construct(
*/
public function getItem(mixed $key): CacheItem
{
return $this->converter->convertToCacheItem($this->cache->getItem($key));
$item = $this->cache->getItem($key);
assert($item instanceof DynamoCacheItem);

return $this->converter->convertToCacheItem($item);
}

/**
Expand All @@ -49,7 +52,7 @@ public function getItems(array $keys = []): iterable
{
return array_map(function (DynamoCacheItem $item) {
return $this->converter->convertToCacheItem($item);
}, $this->cache->getItems($keys));
}, [...$this->cache->getItems($keys)]);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Helper/DynamoDbCacheAdapterDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,21 @@ public function commit(): bool
* @param callable $callback
* @param float|null $beta
* @param array|null $metadata
*
* @codeCoverageIgnore
*
* @throws PsrInvalidArgumentException
*
* @return mixed
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
return $this->originalAdapter->get($key, $callback, $beta, $metadata);
}

/**
* @param string $key
*
* @codeCoverageIgnore
*
* @throws PsrInvalidArgumentException
Expand Down
32 changes: 10 additions & 22 deletions tests/AbstractCacheItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,52 +60,40 @@ protected function getRandomCacheItem(
?DateTimeInterface $dateTime = null
): CacheItemInterface {
return new class($key, $isHit, $value, $dateTime) implements CacheItemInterface {
private $key;

private $isHit;

private $value;

private $dateTime;

public function __construct(
string $key = 'test',
bool $isHit = true,
string $value = 'value',
?DateTimeInterface $dateTime = null
private string $key = 'test',
private bool $isHit = true,
private string $value = 'value',
private ?DateTimeInterface $dateTime = null
) {
$this->key = $key;
$this->isHit = $isHit;
$this->value = $value;
$this->dateTime = $dateTime;
}

public function getKey()
public function getKey(): string
{
return $this->key;
}

public function get()
public function get(): string
{
return $this->value;
}

public function isHit()
public function isHit(): bool
{
return $this->isHit;
}

public function set($value)
public function set(mixed $value): static
{
return $this;
}

public function expiresAt($expiration)
public function expiresAt(?DateTimeInterface $expiration): static
{
return $this;
}

public function expiresAfter($time)
public function expiresAfter(int|\DateInterval|null $time): static
{
return $this;
}
Expand Down

0 comments on commit c8f3356

Please sign in to comment.