Skip to content

Commit 290db74

Browse files
onairmarcEncoreBot
andauthored
Update StaticCache to use late static binding (#65)
Co-authored-by: EncoreBot <ghbot@encoredigitalgroup.com>
1 parent 9702547 commit 290db74

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ c5fafb95fd55e66116028528cf8ba8aa53441904
3333
adee35fd7b993cb4a7cf85df7ee997951af3e907
3434
f3cda4980fdc4c227e00250d7dfcfe4639dc60dc
3535
d676999a6145177a6f61007806f5b95f1df868bd
36+
53d9e752575f07527143ccee692673b8c6793141

src/Objects/Support/StaticCache.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public static function add(BackedEnum|string $key, mixed $value, BackedEnum|stri
1313
$key = self::enum($key);
1414
$partition = self::enum($partition);
1515

16-
self::$cache[$partition][$key] = $value;
16+
self::$cache[static::class][$partition][$key] = $value;
1717
}
1818

1919
public static function contains(BackedEnum|string $key, BackedEnum|string $partition = "default"): bool
2020
{
2121
$key = self::enum($key);
2222
$partition = self::enum($partition);
2323

24-
return isset(self::$cache[$partition][$key]);
24+
return isset(self::$cache[static::class][$partition][$key]);
2525
}
2626

2727
public static function get(BackedEnum|string $key, BackedEnum|string $partition = "default"): mixed
@@ -30,7 +30,7 @@ public static function get(BackedEnum|string $key, BackedEnum|string $partition
3030
$partition = self::enum($partition);
3131

3232
if (self::contains($key, $partition)) {
33-
return self::$cache[$partition][$key];
33+
return self::$cache[static::class][$partition][$key];
3434
}
3535

3636
return null;
@@ -41,21 +41,21 @@ public static function remove(BackedEnum|string $key, BackedEnum|string $partiti
4141
$key = self::enum($key);
4242
$partition = self::enum($partition);
4343

44-
unset(self::$cache[$partition][$key]);
44+
unset(self::$cache[static::class][$partition][$key]);
4545
}
4646

4747
public static function flush(BackedEnum|string|null $partition = null): void
4848
{
4949
if (is_null($partition)) {
50-
self::$cache = [];
50+
self::$cache[static::class] = [];
5151

5252
return;
5353
}
5454

5555
$partition = self::enum($partition);
5656

5757
if (isset(self::$cache[$partition])) {
58-
self::$cache[$partition] = [];
58+
self::$cache[static::class][$partition] = [];
5959
}
6060
}
6161

0 commit comments

Comments
 (0)