Skip to content

Commit 07a064a

Browse files
committed
typehints
1 parent 1440be4 commit 07a064a

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ CustomModel::cacheFor(30)->customGetMethod();
336336
This is how the default key generation function looks like:
337337

338338
```php
339-
public function generatePlainCacheKey(string $method = 'get', $id = null, $appends = null): string
339+
public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string
340340
{
341341
$name = $this->connection->getName();
342342

@@ -359,7 +359,7 @@ class MyCustomBuilder implements QueryCacheModuleInterface
359359
{
360360
use QueryCacheModule;
361361

362-
public function generatePlainCacheKey(string $method = 'get', $id = null, $appends = null): string
362+
public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string
363363
{
364364
$name = $this->connection->getName();
365365

@@ -415,7 +415,7 @@ However, if your builder replaces functions like `find()`, `$id` is needed and
415415
```php
416416
class MyCustomBuilder
417417
{
418-
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], $id = null)
418+
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null)
419419
{
420420
return function () use ($method, $columns, $id) {
421421
$this->avoidCache = true;

src/Contracts/QueryCacheModuleInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ interface QueryCacheModuleInterface
1212
* @param string|null $appends
1313
* @return string
1414
*/
15-
public function generatePlainCacheKey(string $method = 'get', $id = null, $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.
1919
*
2020
* @param string $method
21-
* @param array $columns
21+
* @param array|string $columns
2222
* @param string|null $id
2323
* @return \Closure
2424
*/
25-
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], $id = null);
25+
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null);
2626
}

src/Traits/QueryCacheModule.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ trait QueryCacheModule
6464
/**
6565
* Get the cache from the current query.
6666
*
67+
* @param string $method
6768
* @param array $columns
6869
* @param string|null $id
6970
* @return array
7071
*/
71-
public function getFromQueryCache(string $method = 'get', $columns = ['*'], $id = null)
72+
public function getFromQueryCache(string $method = 'get', array $columns = ['*'], string $id = null)
7273
{
7374
if (is_null($this->columns)) {
7475
$this->columns = $columns;
@@ -90,11 +91,11 @@ public function getFromQueryCache(string $method = 'get', $columns = ['*'], $id
9091
* Get the query cache callback.
9192
*
9293
* @param string $method
93-
* @param array $columns
94+
* @param array|string $columns
9495
* @param string|null $id
9596
* @return \Closure
9697
*/
97-
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], $id = null)
98+
public function getQueryCacheCallback(string $method = 'get', $columns = ['*'], string $id = null)
9899
{
99100
return function () use ($method, $columns) {
100101
$this->avoidCache = true;
@@ -111,7 +112,7 @@ public function getQueryCacheCallback(string $method = 'get', $columns = ['*'],
111112
* @param string|null $appends
112113
* @return string
113114
*/
114-
public function getCacheKey(string $method = 'get', $id = null, $appends = null): string
115+
public function getCacheKey(string $method = 'get', string $id = null, string $appends = null): string
115116
{
116117
$key = $this->generateCacheKey($method, $id, $appends);
117118
$prefix = $this->getCachePrefix();
@@ -127,7 +128,7 @@ public function getCacheKey(string $method = 'get', $id = null, $appends = null)
127128
* @param string|null $appends
128129
* @return string
129130
*/
130-
public function generateCacheKey(string $method = 'get', $id = null, $appends = null): string
131+
public function generateCacheKey(string $method = 'get', string $id = null, string $appends = null): string
131132
{
132133
$key = $this->generatePlainCacheKey($method, $id, $appends);
133134

@@ -146,7 +147,7 @@ public function generateCacheKey(string $method = 'get', $id = null, $appends =
146147
* @param string|null $appends
147148
* @return string
148149
*/
149-
public function generatePlainCacheKey(string $method = 'get', $id = null, $appends = null): string
150+
public function generatePlainCacheKey(string $method = 'get', string $id = null, string $appends = null): string
150151
{
151152
$name = $this->connection->getName();
152153

0 commit comments

Comments
 (0)