Results in the following warning: "Expected parameter of type '\Closure|null', 'int' provided"
An integer is valid here, as per the definition:
/**
* Retrieve an item from the cache by key.
*
* @template TCacheValue
*
* @param array|string $key
* @param TCacheValue|(\Closure(): TCacheValue) $default
* @return (TCacheValue is null ? mixed : TCacheValue)
*/
public function get($key, $default = null): mixed
{
if (is_array($key)) {
return $this->many($key);
}
$this->event(new RetrievingKey($this->getName(), $key));
$value = $this->store->get($this->itemKey($key));
// If we could not find the cache value, we will fire the missed event and get
// the default value for this cache value. This default could be a callback
// so we will execute the value function which will resolve it if needed.
if (is_null($value)) {
$this->event(new CacheMissed($this->getName(), $key));
$value = value($default);
} else {
$this->event(new CacheHit($this->getName(), $key, $value));
}
return $value;
}
Noting specifically:
$value = value($default);
Which when passed an int, will just return the int
/**
* Return the default value of the given value.
*
* @template TValue
* @template TArgs
*
* @param TValue|\Closure(TArgs): TValue $value
* @param TArgs ...$args
* @return TValue
*/
function value($value, ...$args)
{
return $value instanceof Closure ? $value(...$args) : $value;
}
Plugin version
8.3.3.242
Operating system
MacOS
Steps to reproduce
Make use of the Cache facade's get method, and set the default to an integer
Bug description
Hey, appreciate the work on the plugin.
The following code:
Results in the following warning: "Expected parameter of type '\Closure|null', 'int' provided"
An integer is valid here, as per the definition:
Noting specifically:
Which when passed an int, will just return the int
Plugin version
8.3.3.242
Operating system
MacOS
Steps to reproduce
Make use of the Cache facade's get method, and set the default to an integer
Relevant log output
No response