Skip to content

Commit fdffd5c

Browse files
author
James Galecki
committed
pr changes
1 parent 3aff3fb commit fdffd5c

6 files changed

Lines changed: 23 additions & 6 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/coverage/
22
/vendor/
33
clover.xml
4-
/nbproject/private
54
composer.lock
65
phpunit.xml

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A PHP library for memoizing repeated function calls.
1010
[![License](http://img.shields.io/packagist/l/traderinteractive/memoize.svg?style=flat)](https://packagist.org/packages/traderinteractive/memoize)
1111

1212
## Requirements
13-
This library requires PHP 5.4, or newer.
13+
This library requires PHP 7.0, or newer.
1414

1515
## Installation
1616
This package uses [composer](https://getcomposer.org) so you can just add

src/Memoize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ interface Memoize
1313
*
1414
* @return mixed The data requested, optionally pulled from cache
1515
*/
16-
public function memoizeCallable($key, $compute, $cacheTime = null);
16+
public function memoizeCallable(string $key, callable $compute, int $cacheTime = null);
1717
}

src/Memory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ class Memory implements Memoize
1818
* $cacheTime is ignored - this will keep the results around for the lifetime of this instance.
1919
*
2020
* @see Memoize::memoizeCallable
21+
*
22+
* @param string $key
23+
* @param callable $compute
24+
* @param int|null $cacheTime
25+
*
26+
* @return mixed
2127
*/
22-
public function memoizeCallable($key, $compute, $cacheTime = null)
28+
public function memoizeCallable(string $key, callable $compute, int $cacheTime = null)
2329
{
2430
if (array_key_exists($key, $this->cache)) {
2531
return $this->cache[$key];

src/Never.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ class Never implements Memoize
1212
* $cacheTime and $key are ignored - this always calls $compute.
1313
*
1414
* @see Memoize::memoizeCallable
15+
*
16+
* @param string $key
17+
* @param callable $compute
18+
* @param int|null $cacheTime
19+
*
20+
* @return mixed
1521
*/
16-
public function memoizeCallable($key, $compute, $cacheTime = null)
22+
public function memoizeCallable(string $key, callable $compute, int $cacheTime = null)
1723
{
1824
return call_user_func($compute);
1925
}

src/Predis.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ public function __construct(Client $client, bool $refresh = false)
4040
* so make sure that the value you return from $compute is json-encode-able.
4141
*
4242
* @see Memoize::memoizeCallable
43+
*
44+
* @param string $key
45+
* @param callable $compute
46+
* @param int|null $cacheTime
47+
*
48+
* @return mixed
4349
*/
44-
public function memoizeCallable($key, $compute, $cacheTime = null)
50+
public function memoizeCallable(string $key, callable $compute, int $cacheTime = null)
4551
{
4652
if (!$this->refresh) {
4753
try {

0 commit comments

Comments
 (0)