Skip to content

Commit cd98f47

Browse files
committed
Removed deprecations to work with PHP 8.2
1 parent 094d1d1 commit cd98f47

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/Contracts/QueryCacheModuleInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface QueryCacheModuleInterface
1212
* @param string|null $appends
1313
* @return string
1414
*/
15-
public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string;
15+
public function generatePlainCacheKey(string $method = 'get', string $id = null, ?string $appends = null): string;
1616

1717
/**
1818
* Get the query cache callback.
@@ -22,5 +22,5 @@ public function generatePlainCacheKey(string $method = 'get', string $id = null,
2222
* @param string|null $id
2323
* @return \Closure
2424
*/
25-
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null);
25+
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], ?string $id = null);
2626
}

src/FlushQueryCacheObserver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Rennokki\QueryCache;
44

55
use Exception;
6+
use Illuminate\Database\Eloquent\Collection;
67
use Illuminate\Database\Eloquent\Model;
78

89
class FlushQueryCacheObserver
@@ -150,7 +151,7 @@ public function morphToManyUpdatedExistingPivot($relation, Model $model, $ids)
150151
*
151152
* @throws Exception
152153
*/
153-
protected function invalidateCache(Model $model, $relation = null, $pivotedModels = null): void
154+
protected function invalidateCache(Model $model, $relation = null, ?Collection $pivotedModels = null): void
154155
{
155156
$class = get_class($model);
156157

src/Traits/QueryCacheModule.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ trait QueryCacheModule
6969
* @param string|null $id
7070
* @return array
7171
*/
72-
public function getFromQueryCache(string $method = 'get', array $columns = ['*'], string $id = null)
72+
public function getFromQueryCache(string $method = 'get', array $columns = ['*'], ?string $id = null)
7373
{
7474
if (is_null($this->columns)) {
7575
$this->columns = $columns;
@@ -95,7 +95,7 @@ public function getFromQueryCache(string $method = 'get', array $columns = ['*']
9595
* @param string|null $id
9696
* @return \Closure
9797
*/
98-
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null)
98+
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], ?string $id = null)
9999
{
100100
return function () use ($method, $columns) {
101101
$this->avoidCache = true;
@@ -112,7 +112,7 @@ public function getQueryCacheCallback(string $method = 'get', $columns = ['*'],
112112
* @param string|null $appends
113113
* @return string
114114
*/
115-
public function getCacheKey(string $method = 'get', string $id = null, string $appends = null): string
115+
public function getCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string
116116
{
117117
$key = $this->generateCacheKey($method, $id, $appends);
118118
$prefix = $this->getCachePrefix();
@@ -128,7 +128,7 @@ public function getCacheKey(string $method = 'get', string $id = null, string $a
128128
* @param string|null $appends
129129
* @return string
130130
*/
131-
public function generateCacheKey(string $method = 'get', string $id = null, string $appends = null): string
131+
public function generateCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string
132132
{
133133
$key = $this->generatePlainCacheKey($method, $id, $appends);
134134

@@ -147,7 +147,7 @@ public function generateCacheKey(string $method = 'get', string $id = null, stri
147147
* @param string|null $appends
148148
* @return string
149149
*/
150-
public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string
150+
public function generatePlainCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string
151151
{
152152
$name = $this->connection->getName();
153153

src/Traits/QueryCacheable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Rennokki\QueryCache\Traits;
44

5+
use Illuminate\Database\Eloquent\Collection;
56
use Rennokki\QueryCache\FlushQueryCacheObserver;
67
use Rennokki\QueryCache\Query\Builder;
78

@@ -68,7 +69,7 @@ protected function getCacheBaseTags(): array
6869
* @param \Illuminate\Database\Eloquent\Collection|null $pivotedModels
6970
* @return array
7071
*/
71-
public function getCacheTagsToInvalidateOnUpdate($relation = null, $pivotedModels = null): array
72+
public function getCacheTagsToInvalidateOnUpdate($relation = null, ?Collection $pivotedModels = null): array
7273
{
7374
/** @var \Illuminate\Database\Eloquent\Model $this */
7475
return $this->getCacheBaseTags();

tests/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Chelout\RelationshipEvents\Concerns\HasBelongsToManyEvents;
66
use Chelout\RelationshipEvents\Traits\HasRelationshipObservables;
7+
use Illuminate\Database\Eloquent\Collection;
78
use Illuminate\Foundation\Auth\User as Authenticatable;
89
use Rennokki\QueryCache\Traits\QueryCacheable;
910

@@ -42,7 +43,7 @@ protected function cacheForValue()
4243
return 3600;
4344
}
4445

45-
public function getCacheTagsToInvalidateOnUpdate($relation = null, $pivotedModels = null): array
46+
public function getCacheTagsToInvalidateOnUpdate($relation = null, ?Collection $pivotedModels = null): array
4647
{
4748
if ($relation === 'roles') {
4849
$tags = array_reduce($pivotedModels->all(), function ($tags, Role $role) {

tests/TestCase.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ public function setUp(): void
1515
{
1616
parent::setUp();
1717

18-
if ($this->getProvidedData() && method_exists(Model::class, 'preventAccessingMissingAttributes')) {
18+
if (method_exists($this, 'getProvidedData')
19+
&& $this->getProvidedData()
20+
&& method_exists(Model::class, 'preventAccessingMissingAttributes')
21+
) {
1922
[$strict] = $this->getProvidedData();
2023
Model::preventAccessingMissingAttributes($strict);
2124
}
@@ -99,7 +102,7 @@ protected function clearCache()
99102
* @param array|null $tags
100103
* @return mixed
101104
*/
102-
protected function getCacheWithTags(string $key, $tags = null)
105+
protected function getCacheWithTags(string $key, ?array $tags = null)
103106
{
104107
return $this->driverSupportsTags()
105108
? Cache::tags($tags)->get($key)

0 commit comments

Comments
 (0)