From 66bbb48f652370d274f7543c7397be8f778cf88e Mon Sep 17 00:00:00 2001 From: JonPurvis Date: Tue, 2 Dec 2025 20:55:06 +0000 Subject: [PATCH 1/3] change memory store to static --- src/Stores/MemoryStore.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Stores/MemoryStore.php b/src/Stores/MemoryStore.php index 4299bd0..530def0 100644 --- a/src/Stores/MemoryStore.php +++ b/src/Stores/MemoryStore.php @@ -13,14 +13,14 @@ class MemoryStore implements RateLimitStore * * @var array */ - protected array $store = []; + protected static array $store = []; /** * Get a rate limit from the store */ public function get(string $key): ?string { - return $this->store[$key] ?? null; + return self::$store[$key] ?? null; } /** @@ -28,7 +28,7 @@ public function get(string $key): ?string */ public function set(string $key, string $value, int $ttl): bool { - $this->store[$key] = $value; + self::$store[$key] = $value; return true; } @@ -40,6 +40,6 @@ public function set(string $key, string $value, int $ttl): bool */ public function getStore(): array { - return $this->store; + return self::$store; } } From 71c6d14ae266373928a83411e0ae8e4e8574591e Mon Sep 17 00:00:00 2001 From: JonPurvis Date: Tue, 2 Dec 2025 21:29:45 +0000 Subject: [PATCH 2/3] wip --- src/Stores/MemoryStore.php | 8 ++++++++ tests/Pest.php | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Stores/MemoryStore.php b/src/Stores/MemoryStore.php index 530def0..80cc1b7 100644 --- a/src/Stores/MemoryStore.php +++ b/src/Stores/MemoryStore.php @@ -42,4 +42,12 @@ public function getStore(): array { return self::$store; } + + /** + * Clear the store + */ + public static function clear(): void + { + self::$store = []; + } } diff --git a/tests/Pest.php b/tests/Pest.php index 0bc9ce1..97c8054 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -14,8 +14,16 @@ */ use Orchestra\Testbench\TestCase as LaravelTestCase; +use Saloon\RateLimitPlugin\Stores\MemoryStore; -uses(LaravelTestCase::class)->in('./Laravel'); +uses(LaravelTestCase::class) + ->beforeEach(fn () => MemoryStore::clear()) + ->in('./Laravel'); + +uses() + ->beforeEach(fn () => MemoryStore::clear()) + ->afterEach(fn () => MemoryStore::clear()) + ->in('./'); /* |-------------------------------------------------------------------------- From e2bbc29c64f57cfd5eb80253b602c79600f4ad8c Mon Sep 17 00:00:00 2001 From: JonPurvis Date: Tue, 2 Dec 2025 21:42:38 +0000 Subject: [PATCH 3/3] run cs fixer --- tests/Pest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Pest.php b/tests/Pest.php index 97c8054..78c84f2 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -13,8 +13,8 @@ | */ -use Orchestra\Testbench\TestCase as LaravelTestCase; use Saloon\RateLimitPlugin\Stores\MemoryStore; +use Orchestra\Testbench\TestCase as LaravelTestCase; uses(LaravelTestCase::class) ->beforeEach(fn () => MemoryStore::clear())