diff --git a/src/Contracts/QueryCacheModuleInterface.php b/src/Contracts/QueryCacheModuleInterface.php index 78a7f0d..0458986 100644 --- a/src/Contracts/QueryCacheModuleInterface.php +++ b/src/Contracts/QueryCacheModuleInterface.php @@ -12,7 +12,7 @@ interface QueryCacheModuleInterface * @param string|null $appends * @return string */ - public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string; + public function generatePlainCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string; /** * Get the query cache callback. @@ -22,5 +22,5 @@ public function generatePlainCacheKey(string $method = 'get', string $id = null, * @param string|null $id * @return \Closure */ - public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null); + public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], ?string $id = null); } diff --git a/src/FlushQueryCacheObserver.php b/src/FlushQueryCacheObserver.php index 7ca7ce2..f99cc43 100644 --- a/src/FlushQueryCacheObserver.php +++ b/src/FlushQueryCacheObserver.php @@ -3,6 +3,7 @@ namespace Rennokki\QueryCache; use Exception; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; class FlushQueryCacheObserver @@ -150,7 +151,7 @@ public function morphToManyUpdatedExistingPivot($relation, Model $model, $ids) * * @throws Exception */ - protected function invalidateCache(Model $model, $relation = null, $pivotedModels = null): void + protected function invalidateCache(Model $model, ?string $relation = null, ?Collection $pivotedModels = null): void { $class = get_class($model); diff --git a/src/Traits/QueryCacheModule.php b/src/Traits/QueryCacheModule.php index 79caa36..1eccc98 100644 --- a/src/Traits/QueryCacheModule.php +++ b/src/Traits/QueryCacheModule.php @@ -69,7 +69,7 @@ trait QueryCacheModule * @param string|null $id * @return array */ - public function getFromQueryCache(string $method = 'get', array $columns = ['*'], string $id = null) + public function getFromQueryCache(string $method = 'get', array $columns = ['*'], ?string $id = null) { if (is_null($this->columns)) { $this->columns = $columns; @@ -95,7 +95,7 @@ public function getFromQueryCache(string $method = 'get', array $columns = ['*'] * @param string|null $id * @return \Closure */ - public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null) + public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], ?string $id = null) { return function () use ($method, $columns) { $this->avoidCache = true; @@ -112,7 +112,7 @@ public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], * @param string|null $appends * @return string */ - public function getCacheKey(string $method = 'get', string $id = null, string $appends = null): string + public function getCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string { $key = $this->generateCacheKey($method, $id, $appends); $prefix = $this->getCachePrefix(); @@ -128,7 +128,7 @@ public function getCacheKey(string $method = 'get', string $id = null, string $a * @param string|null $appends * @return string */ - public function generateCacheKey(string $method = 'get', string $id = null, string $appends = null): string + public function generateCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string { $key = $this->generatePlainCacheKey($method, $id, $appends); @@ -147,7 +147,7 @@ public function generateCacheKey(string $method = 'get', string $id = null, stri * @param string|null $appends * @return string */ - public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string + public function generatePlainCacheKey(string $method = 'get', ?string $id = null, ?string $appends = null): string { $name = $this->connection->getName(); diff --git a/src/Traits/QueryCacheable.php b/src/Traits/QueryCacheable.php index c9f85a8..91bb85d 100644 --- a/src/Traits/QueryCacheable.php +++ b/src/Traits/QueryCacheable.php @@ -2,6 +2,7 @@ namespace Rennokki\QueryCache\Traits; +use Illuminate\Database\Eloquent\Collection; use Rennokki\QueryCache\FlushQueryCacheObserver; use Rennokki\QueryCache\Query\Builder; @@ -68,7 +69,7 @@ protected function getCacheBaseTags(): array * @param \Illuminate\Database\Eloquent\Collection|null $pivotedModels * @return array */ - public function getCacheTagsToInvalidateOnUpdate($relation = null, $pivotedModels = null): array + public function getCacheTagsToInvalidateOnUpdate(?string $relation = null, ?Collection $pivotedModels = null): array { /** @var \Illuminate\Database\Eloquent\Model $this */ return $this->getCacheBaseTags();