Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Required parameter $function follows optional parameter $conditions [PHP8] #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,19 @@ protected function isRemote($file)
*
* @param string $filename the cache file name
* @param array $conditions an array of conditions about expiration
* @param \Closure $function the closure to call if the file does not exist
* @param \Closure|null $function the closure to call if the file does not exist
* @param bool $file returns the cache file or the file contents
* @param bool $actual returns the actual cache file
* @return string
* @throws \InvalidArgumentException
*/
public function getOrCreate($filename, array $conditions = array(), $function, $file = false, $actual = false)
{
public function getOrCreate(
$filename,
array $conditions = array(),
$function = null,
$file = false,
$actual = false
) {
if (!is_callable($function)) {
throw new \InvalidArgumentException('The argument $function should be callable');
}
Expand Down Expand Up @@ -353,12 +358,12 @@ public function getOrCreate($filename, array $conditions = array(), $function, $
*
* @param string $filename the cache file name
* @param array $conditions an array of conditions about expiration
* @param \Closure $function the closure to call if the file does not exist
* @param \Closure|null $function the closure to call if the file does not exist
* @param bool $actual returns the actual cache file
* @return string
* @throws \InvalidArgumentException
*/
public function getOrCreateFile($filename, array $conditions = array(), $function, $actual = false)
public function getOrCreateFile($filename, array $conditions = array(), $function = null, $actual = false)
{
return $this->getOrCreate($filename, $conditions, $function, true, $actual);
}
Expand Down
16 changes: 11 additions & 5 deletions CacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,30 @@ public function get($filename, array $conditions = array());
*
* @param string $filename the cache file name
* @param array $conditions an array of conditions about expiration
* @param \Closure $function the closure to call if the file does not exist
* @param \Closure|null $function the closure to call if the file does not exist
* @param bool $file returns the cache file or the file contents
* @param bool $actual returns the actual cache file
* @return string
* @throws \InvalidArgumentException
*/
public function getOrCreate($filename, array $conditions = array(), $function, $file = false, $actual = false);
public function getOrCreate(
$filename,
array $conditions = array(),
$function = null,
$file = false,
$actual = false
);

/**
* Alias to getOrCreate with $file = true
*
* @param string $filename the cache file name
* @param array $conditions an array of conditions about expiration
* @param \Closure $function the closure to call if the file does not exist
* @param \Closure|null $function the closure to call if the file does not exist
* @param bool $actual returns the actual cache file
* @return string
* @throws \InvalidArgumentException
*/
public function getOrCreateFile($filename, array $conditions = array(), $function, $actual = false);
public function getOrCreateFile($filename, array $conditions = array(), $function = null, $actual = false);

}
}