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

Symfony cache v6 support #15

Merged
merged 11 commits into from
Feb 1, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
cs:
uses: ray-di/.github/.github/workflows/coding-standards.yml@v1
with:
php_version: 8.1
php_version: 8.2
5 changes: 3 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
dependencies:
- lowest
- highest
Expand Down Expand Up @@ -59,12 +60,12 @@ jobs:
- name: Install lowest dependencies
if: ${{ matrix.dependencies == 'lowest' }}
run: >-
composer update --prefer-lowest --no-interaction --no-progress
composer update --prefer-lowest --no-interaction --no-progress --no-scripts
--no-suggest

- name: Install highest dependencies
if: ${{ matrix.dependencies == 'highest' }}
run: composer update --no-interaction --no-progress --no-suggest
run: composer update --no-interaction --no-progress --no-suggest --no-scripts

- name: Run test suite
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
sa:
uses: ray-di/.github/.github/workflows/static-analysis.yml@v1
with:
php_version: 8.1
php_version: 8.2
has_crc_config: true
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
],
"require": {
"php": "^7.3 || ^8.0",
"psr/cache": "^1.0.1",
"psr/cache": "^1.0.1 || ^2.0 || ^3.0",
"ray/di": "^2.13.2",
"symfony/cache": "^5.3.4",
"symfony/cache": "^5.3.4 || ^6.0",
"doctrine/annotations": "^1.13",
"psr/simple-cache": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"ray/aop": "^2.10.4"
},
"require-dev": {
"ext-redis": "*",
"ext-memcached": "*",
"bamarni/composer-bin-plugin": "^1.4",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5.28"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
phpVersion="7.4"
>
<projectFiles>
<directory name="src" />
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/CacheDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD)]
#[Qualifier]
final class CacheDir
{
/** @var string */
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/CacheNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD)]
#[Qualifier]
final class CacheNamespace
{
/** @var string */
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD)]
#[Qualifier]
final class Local
{
/** @var string */
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/MemcacheConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_METHOD)]
#[Qualifier]
final class MemcacheConfig
{
/** @var string */
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/RedisConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute, Qualifier]
#[Attribute]
#[Qualifier]
final class RedisConfig
{
/** @var string */
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/RedisInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* @Annotation
* @Qualifier()
*/
#[Attribute, Qualifier]
#[Attribute]
#[Qualifier]
final class RedisInstance
{
}
3 changes: 2 additions & 1 deletion src/Annotation/Shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* @Qualifier
* @NamedArgumentConstructor
*/
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD), Qualifier]
#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_METHOD)]
#[Qualifier]
final class Shared
{
/** @var string */
Expand Down
2 changes: 2 additions & 0 deletions src/ApcuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
class ApcuAdapter extends OriginAdapter implements Serializable
{
use SerializableTrait;

public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, ?MarshallerInterface $marshaller = null)
{
$this->args = func_get_args();

parent::__construct($namespace, $defaultLifetime, $directory, $marshaller);
}
}
1 change: 1 addition & 0 deletions src/CacheDirModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class CacheDirModule extends AbstractModule
public function __construct(string $cacheDir, ?AbstractModule $module = null)
{
$this->cacheDir = $cacheDir;

parent::__construct($module);
}

Expand Down
1 change: 1 addition & 0 deletions src/CacheNamespaceModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class CacheNamespaceModule extends AbstractModule
public function __construct(string $namespace, ?AbstractModule $module = null)
{
$this->namespace = $namespace;

parent::__construct($module);
}

Expand Down
2 changes: 2 additions & 0 deletions src/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
class FilesystemAdapter extends OriginAdapter implements Serializable
{
use SerializableTrait;
Expand All @@ -25,6 +26,7 @@ class FilesystemAdapter extends OriginAdapter implements Serializable
public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, ?MarshallerInterface $marshaller = null)
{
$this->args = func_get_args();

parent::__construct($namespace, $defaultLifetime, $directory, $marshaller);
}
}
4 changes: 1 addition & 3 deletions src/MemcachedProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
use Ray\Di\ProviderInterface;
use Ray\PsrCacheModule\Annotation\MemcacheConfig;

/**
* @implements ProviderInterface<Memcached>
*/
/** @implements ProviderInterface<Memcached> */
class MemcachedProvider implements ProviderInterface
{
/**
Expand Down
6 changes: 3 additions & 3 deletions src/PhpFileAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

use function func_get_args;

/** @psalm-suppress PropertyNotSetInConstructor */
class PhpFileAdapter extends OriginAdapter implements Serializable
{
use SerializableTrait;

/**
* @CacheNamespace("namespace")
*/
/** @CacheNamespace("namespace") */
#[CacheNamespace('namespace')]
public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, bool $appendOnly = false)
{
$this->args = func_get_args();

parent::__construct($namespace, $defaultLifetime, $directory, $appendOnly);
}
}
1 change: 1 addition & 0 deletions src/Psr6MemcachedModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct(string $servers, ?AbstractModule $module = null)
$this->servers = array_map(static function ($serverString) {
return explode(':', $serverString);
}, explode(',', $servers));

parent::__construct($module);
}

Expand Down
1 change: 1 addition & 0 deletions src/Psr6RedisModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class Psr6RedisModule extends AbstractModule
public function __construct(string $server, ?AbstractModule $module = null)
{
$this->server = explode(':', $server);

parent::__construct($module);
}

Expand Down
4 changes: 1 addition & 3 deletions src/RedisProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

use function sprintf;

/**
* @implements ProviderInterface<Redis>
*/
/** @implements ProviderInterface<Redis> */
class RedisProvider implements ProviderInterface
{
/** @var list<string> */
Expand Down
8 changes: 2 additions & 6 deletions src/SerializableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ trait SerializableTrait
/** @var array<mixed> */
private $args;

/**
* @return array<mixed>
*/
/** @return array<mixed> */
public function __serialize(): array
{
return $this->args;
}

/**
* @param array<mixed> $data
*/
/** @param array<mixed> $data */
public function __unserialize(array $data): void
{
call_user_func_array([$this, '__construct'], $data); // @phpstan-ignore-line
Expand Down
4 changes: 1 addition & 3 deletions tests/ApcuAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public function testSerialize(): string
return $string;
}

/**
* @depends testSerialize
*/
/** @depends testSerialize */
public function testUnserialize(string $string): void
{
$this->assertInstanceOf(ApcuAdapter::class, unserialize($string));
Expand Down
4 changes: 1 addition & 3 deletions tests/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public function testSerialize(): string
return $string;
}

/**
* @depends testSerialize
*/
/** @depends testSerialize */
public function testUnserialize(string $string): void
{
$this->assertInstanceOf(FilesystemAdapter::class, unserialize($string));
Expand Down
4 changes: 1 addition & 3 deletions tests/PhpFileAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public function testSerialize(): string
return $string;
}

/**
* @depends testSerialize
*/
/** @depends testSerialize */
public function testUnserialize(string $string): void
{
$this->assertInstanceOf(PhpFileAdapter::class, unserialize($string));
Expand Down
18 changes: 9 additions & 9 deletions vendor-bin/tools/composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"require": {
"doctrine/coding-standard": "^9.0",
"phpmd/phpmd": "^2.9",
"phpmetrics/phpmetrics": "^2.7",
"phpstan/phpstan": "^1.0.2",
"psalm/plugin-phpunit": "^0.13",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.2"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"bamarni/composer-bin-plugin": true
}
},
"require-dev": {
"vimeo/psalm": "^5.6",
"psalm/plugin-phpunit": "^0.18.4",
"phpstan/phpstan": "^1.9",
"phpmetrics/phpmetrics": "^2.8",
"squizlabs/php_codesniffer": "^3.7",
"doctrine/coding-standard": "^11.1",
"phpmd/phpmd": "^2.13"
}
}
Loading