From c082abe5ddc4d4436072c2f320bbd9ac690eafa5 Mon Sep 17 00:00:00 2001 From: "Kouhei.Sano" Date: Thu, 9 May 2024 08:00:22 +0900 Subject: [PATCH 1/3] fix: Typo MemcachdAdapter --- src/{MemcachdAdapter.php => MemcachedAdapter.php} | 2 +- tests/MemcachedAdapterTest.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) rename src/{MemcachdAdapter.php => MemcachedAdapter.php} (93%) diff --git a/src/MemcachdAdapter.php b/src/MemcachedAdapter.php similarity index 93% rename from src/MemcachdAdapter.php rename to src/MemcachedAdapter.php index b2160d0..b360a00 100644 --- a/src/MemcachdAdapter.php +++ b/src/MemcachedAdapter.php @@ -15,7 +15,7 @@ use function func_get_args; /** @psalm-suppress PropertyNotSetInConstructor */ -class MemcachdAdapter extends OriginAdapter implements Serializable +class MemcachedAdapter extends OriginAdapter implements Serializable { use SerializableTrait; diff --git a/tests/MemcachedAdapterTest.php b/tests/MemcachedAdapterTest.php index 5cdf9eb..301ead3 100644 --- a/tests/MemcachedAdapterTest.php +++ b/tests/MemcachedAdapterTest.php @@ -15,11 +15,11 @@ class MemcachedAdapterTest extends TestCase { - /** @return array{0:string, 1: MemcachdAdapter} */ + /** @return array{0:string, 1: MemcachedAdapter} */ public function testSerialize(): array { $provider = new MemcachedProvider([['127.0.0.1', '11211']]); - $adapter = new MemcachdAdapter($provider); + $adapter = new MemcachedAdapter($provider); $adapter->get('foo', static function (ItemInterface $item) { return 'foobar'; }); @@ -34,19 +34,19 @@ public function testSerialize(): array } /** - * @param array{0:string, 1: MemcachdAdapter} $adapters + * @param array{0:string, 1: MemcachedAdapter} $adapters * * @depends testSerialize */ public function testUnserialize(array $adapters): void { - $this->assertInstanceOf(MemcachdAdapter::class, $adapters[1]); + $this->assertInstanceOf(MemcachedAdapter::class, $adapters[1]); $this->assertSame('foobar', $adapters[1]->get('foo', static function (ItemInterface $item) { return '_no_serve_in_object'; })); $adapter0 = unserialize($adapters[0]); - $this->assertInstanceOf(MemcachdAdapter::class, $adapter0); + $this->assertInstanceOf(MemcachedAdapter::class, $adapter0); $this->assertSame('foobar', $adapter0->get('foo', static function (ItemInterface $item) { return '_no_serve_in_serialize'; })); @@ -59,11 +59,11 @@ protected function configure(): void { $this->install(new CacheNamespaceModule('a')); $this->install(new CacheDirModule('/tmp/a')); - $this->bind(AbstractAdapter::class)->to(MemcachdAdapter::class); + $this->bind(AbstractAdapter::class)->to(MemcachedAdapter::class); $this->install(new Psr6MemcachedModule('127.0.0.1:6379:1')); } }); $adapter = $injector->getInstance(AbstractAdapter::class); - $this->assertInstanceOf(MemcachdAdapter::class, $adapter); + $this->assertInstanceOf(MemcachedAdapter::class, $adapter); } } From ab748d9de947eb37774f0ea1563c63269779d66a Mon Sep 17 00:00:00 2001 From: "Kouhei.Sano" Date: Sun, 12 May 2024 13:22:16 +0900 Subject: [PATCH 2/3] chore: Add MemcachdAdapter into deprecated --- composer.json | 2 +- src-deprecated/MemcachdAdapter.php | 39 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src-deprecated/MemcachdAdapter.php diff --git a/composer.json b/composer.json index faae9ac..b723de9 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "autoload": { "psr-4": { - "Ray\\PsrCacheModule\\": ["src/", "src-deprecated"] + "Ray\\PsrCacheModule\\": ["src/", "src-deprecated/"] } }, "autoload-dev": { diff --git a/src-deprecated/MemcachdAdapter.php b/src-deprecated/MemcachdAdapter.php new file mode 100644 index 0000000..ff60ca5 --- /dev/null +++ b/src-deprecated/MemcachdAdapter.php @@ -0,0 +1,39 @@ + $clientProvider + * + * @Named("memcached") + * @CacheNamespace("namespace") + */ + #[CacheNamespace('namespace')] + #[Named('memcached')] + public function __construct(ProviderInterface $clientProvider, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null) + { + $this->args = func_get_args(); + + parent::__construct($clientProvider->get(), $namespace, $defaultLifetime, $marshaller); + } +} From 60deff0141ce49e6a875e74a2ea473df3b82a2a3 Mon Sep 17 00:00:00 2001 From: "Kouhei.Sano" Date: Sun, 12 May 2024 17:58:46 +0900 Subject: [PATCH 3/3] chore: Remove PHPDoc for psalm --- src-deprecated/MemcachdAdapter.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src-deprecated/MemcachdAdapter.php b/src-deprecated/MemcachdAdapter.php index ff60ca5..5f1341b 100644 --- a/src-deprecated/MemcachdAdapter.php +++ b/src-deprecated/MemcachdAdapter.php @@ -14,10 +14,7 @@ use function func_get_args; -/** - * @psalm-suppress PropertyNotSetInConstructor - * @deprecated Use \Ray\PsrCacheModule\MemcachedAdapter instead - */ +/** @deprecated Use \Ray\PsrCacheModule\MemcachedAdapter instead */ class MemcachdAdapter extends OriginAdapter implements Serializable { use SerializableTrait;