Browse Source

PHP 7 or bust!

Timothy J. Warren 2 years ago
parent
commit
4f6ae064da

+ 1
- 1
RoboFile.php View File

@@ -1,4 +1,4 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 if ( ! function_exists('glob_recursive'))
3 3
 {
4 4
 	// Does not support flag GLOB_BRACE

+ 3
- 2
build/header_comment.txt View File

@@ -3,7 +3,7 @@
3 3
  *
4 4
  * A Caching library implementing psr/cache
5 5
  *
6
- * PHP version 5.6
6
+ * PHP version 7.0
7 7
  *
8 8
  * @package     Banker
9 9
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -11,4 +11,5 @@
11 11
  * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
12 12
  * @version     1.0.0
13 13
  * @link        https://git.timshomepage.net/timw4mail/banker
14
- */
14
+ */
15
+

+ 24
- 14
build/update_header_comments.php View File

@@ -1,7 +1,8 @@
1 1
 <?php
2 2
 
3 3
 $file_patterns = [
4
-	'src/*.php'
4
+	'src/*.php',
5
+	'tests/*.php'
5 6
 ];
6 7
 
7 8
 if ( ! function_exists('glob_recursive'))
@@ -23,21 +24,30 @@ if ( ! function_exists('glob_recursive'))
23 24
 
24 25
 function get_text_to_replace($tokens)
25 26
 {
26
-	if ($tokens[0][0] !== T_OPEN_TAG)
27
-	{
28
-		return NULL;
29
-	}
27
+	$output = '';
30 28
 
31
-	// If there is already a docblock, as the second token after the
32
-	// open tag, get the contents of that token to replace
33
-	if ($tokens[1][0] === T_DOC_COMMENT)
34
-	{
35
-		return "<?php\n" . $tokens[1][1];
36
-	}
37
-	else if ($tokens[1][0] !== T_DOC_COMMENT)
29
+	// Tokens have the follow structure if arrays:
30
+	// [0] => token type constant
31
+	// [1] => raw sytax parsed to that token
32
+	// [2] => line number
33
+	foreach($tokens as $token)
38 34
 	{
39
-		return "<?php";
35
+		// Since we only care about opening docblocks,
36
+		// bail out when we get to the namespace token
37
+		if (is_array($token) && $token[0] === T_NAMESPACE)
38
+		{
39
+			break;
40
+		}
41
+
42
+		if (is_array($token))
43
+		{
44
+			$token = $token[1];
45
+		}
46
+
47
+		$output .= $token;
40 48
 	}
49
+
50
+	return $output;
41 51
 }
42 52
 
43 53
 function get_tokens($source)
@@ -54,7 +64,7 @@ function replace_files(array $files, $template)
54 64
 		$text_to_replace = get_text_to_replace($tokens);
55 65
 
56 66
 		$header = file_get_contents(__DIR__ . $template);
57
-		$new_text = "<?php\n{$header}";
67
+		$new_text = "<?php declare(strict_types=1);\n{$header}";
58 68
 
59 69
 		$new_source = str_replace($text_to_replace, $new_text, $source);
60 70
 		file_put_contents($file, $new_source);

+ 7
- 7
src/Driver/AbstractDriver.php View File

@@ -1,17 +1,17 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9
- * @package	 Banker
10
- * @author	  Timothy J. Warren <tim@timshomepage.net>
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11 11
  * @copyright   2016  Timothy J. Warren
12
- * @license	 http://www.opensource.org/licenses/mit-license.html  MIT License
13
- * @version	 1.0.0
14
- * @link		https://git.timshomepage.net/timw4mail/banker
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15 15
  */
16 16
 
17 17
 namespace Aviat\Banker\Driver;

+ 16
- 16
src/Driver/DriverInterface.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -24,10 +24,10 @@ interface DriverInterface {
24 24
 	/**
25 25
 	 * See if a key exists in the cache
26 26
 	 *
27
-	 * @param $key
27
+	 * @param string $key
28 28
 	 * @return bool
29 29
 	 */
30
-	public function exists($key);
30
+	public function exists(string $key): bool;
31 31
 
32 32
 	/**
33 33
 	 * Set a cached value
@@ -37,15 +37,15 @@ interface DriverInterface {
37 37
 	 * @param int $expires
38 38
 	 * @return DriverInterface
39 39
 	 */
40
-	public function set($key, $value, $expires = 0);
41
-	
40
+	public function set(string $key, $value, int $expires = 0): DriverInterface;
41
+
42 42
 	/**
43 43
 	 * Get the value for the selected cache key
44 44
 	 *
45 45
 	 * @param string $key
46 46
 	 * @return mixed
47 47
 	 */
48
-	public function get($key);
48
+	public function get(string $key);
49 49
 
50 50
 	/**
51 51
 	 * Retrieve a set of values by their cache key
@@ -53,31 +53,31 @@ interface DriverInterface {
53 53
 	 * @param string[] $keys
54 54
 	 * @return array
55 55
 	 */
56
-	public function getMultiple(array $keys = []);
57
-	
56
+	public function getMultiple(array $keys = []): array;
57
+
58 58
 	/**
59 59
 	 * Remove an item from the cache
60 60
 	 *
61 61
 	 * @param string $key
62 62
 	 * @return boolean
63 63
 	 */
64
-	public function delete($key);
65
-	
64
+	public function delete(string $key): bool;
65
+
66 66
 	/**
67 67
 	 * Remove multiple items from the cache
68 68
 	 *
69 69
 	 * @param string[] $keys
70 70
 	 * @return boolean
71 71
 	 */
72
-	public function deleteMultiple(array $keys = []);
73
-	
72
+	public function deleteMultiple(array $keys = []): bool;
73
+
74 74
 	/**
75 75
 	 * Empty the cache
76 76
 	 *
77 77
 	 * @return boolean
78 78
 	 */
79
-	public function flush();
80
-	
79
+	public function flush(): bool;
80
+
81 81
 	/**
82 82
 	 * Set the specified key to expire at the given time
83 83
 	 *
@@ -85,5 +85,5 @@ interface DriverInterface {
85 85
 	 * @param int $expires
86 86
 	 * @return boolean
87 87
 	 */
88
-	public function expiresAt($key, $expires);
88
+	public function expiresAt(string $key, int $expires): bool;
89 89
 }

+ 15
- 13
src/Driver/MemcacheDriver.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -43,7 +43,7 @@ class MemcacheDriver extends AbstractDriver {
43 43
 
44 44
 		$method = ($config['persistent'] === TRUE) ? 'pconnect' : 'connect';
45 45
 
46
-		$this->conn->$method($config['host'], $config['port']);
46
+		$this->conn->$method($config['host'], (int) $config['port']);
47 47
 	}
48 48
 
49 49
 	/**
@@ -60,7 +60,7 @@ class MemcacheDriver extends AbstractDriver {
60 60
 	 * @param string $key
61 61
 	 * @return bool
62 62
 	 */
63
-	public function exists($key)
63
+	public function exists(string $key): bool
64 64
 	{
65 65
 		return $this->conn->get($key) !== FALSE;
66 66
 	}
@@ -71,7 +71,7 @@ class MemcacheDriver extends AbstractDriver {
71 71
 	 * @param string $key
72 72
 	 * @return mixed
73 73
 	 */
74
-	public function get($key)
74
+	public function get(string $key)
75 75
 	{
76 76
 		return $this->conn->get($key);
77 77
 	}
@@ -82,7 +82,7 @@ class MemcacheDriver extends AbstractDriver {
82 82
 	 * @param string[] $keys
83 83
 	 * @return array
84 84
 	 */
85
-	public function getMultiple(array $keys = [])
85
+	public function getMultiple(array $keys = []): array
86 86
 	{
87 87
 		return $this->conn->get($keys);
88 88
 	}
@@ -95,7 +95,7 @@ class MemcacheDriver extends AbstractDriver {
95 95
 	 * @param int $expires
96 96
 	 * @return DriverInterface
97 97
 	 */
98
-	public function set($key, $value, $expires = 0)
98
+	public function set(string $key, $value, int $expires = 0): DriverInterface
99 99
 	{
100 100
 		if ($this->exists($key))
101 101
 		{
@@ -115,7 +115,7 @@ class MemcacheDriver extends AbstractDriver {
115 115
 	 * @param string $key
116 116
 	 * @return boolean
117 117
 	 */
118
-	public function delete($key)
118
+	public function delete(string $key): bool
119 119
 	{
120 120
 		return $this->conn->delete($key);
121 121
 	}
@@ -126,7 +126,7 @@ class MemcacheDriver extends AbstractDriver {
126 126
 	 * @param string[] $keys
127 127
 	 * @return boolean
128 128
 	 */
129
-	public function deleteMultiple(array $keys = [])
129
+	public function deleteMultiple(array $keys = []): bool
130 130
 	{
131 131
 		// Iteratively delete each item, using a boolean
132 132
 		// 'and' operation to return false if any deletion fails
@@ -140,7 +140,7 @@ class MemcacheDriver extends AbstractDriver {
140 140
 	 *
141 141
 	 * @return boolean
142 142
 	 */
143
-	public function flush()
143
+	public function flush(): bool
144 144
 	{
145 145
 		return $this->conn->flush();
146 146
 	}
@@ -150,13 +150,15 @@ class MemcacheDriver extends AbstractDriver {
150 150
 	 *
151 151
 	 * @param string $key
152 152
 	 * @param int $expires
153
-	 * @return DriverInterface
153
+	 * @return boolean
154 154
 	 */
155
-	public function expiresAt($key, $expires)
155
+	public function expiresAt(string $key, int $expires): bool
156 156
 	{
157 157
 		$value = $this->get($key);
158 158
 		$timediff = $expires - time();
159 159
 
160
-		return $this->set($key, $value, $timediff);
160
+		$this->set($key, $value, $timediff);
161
+
162
+		return TRUE;
161 163
 	}
162 164
 }

+ 11
- 11
src/Driver/MemcachedDriver.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -46,7 +46,7 @@ class MemcachedDriver extends AbstractDriver {
46 46
 		{
47 47
 			$this->conn = new Memcached();
48 48
 			$this->conn->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
49
-			$this->conn->addServer($config['host'], $config['port']);
49
+			$this->conn->addServer($config['host'], (int) $config['port']);
50 50
 
51 51
 			// @codeCoverageIgnoreStart
52 52
 			if ( ! empty($options))
@@ -77,7 +77,7 @@ class MemcachedDriver extends AbstractDriver {
77 77
 	 * @param string $key
78 78
 	 * @return bool
79 79
 	 */
80
-	public function exists($key)
80
+	public function exists(string $key): bool
81 81
 	{
82 82
 		return $this->conn->get($key) !== FALSE;
83 83
 	}
@@ -88,7 +88,7 @@ class MemcachedDriver extends AbstractDriver {
88 88
 	 * @param string $key
89 89
 	 * @return mixed
90 90
 	 */
91
-	public function get($key)
91
+	public function get(string $key)
92 92
 	{
93 93
 		return $this->conn->get($key);
94 94
 	}
@@ -99,7 +99,7 @@ class MemcachedDriver extends AbstractDriver {
99 99
 	 * @param string[] $keys
100 100
 	 * @return array
101 101
 	 */
102
-	public function getMultiple(array $keys = [])
102
+	public function getMultiple(array $keys = []): array
103 103
 	{
104 104
 		return $this->conn->getMulti($keys);
105 105
 	}
@@ -112,7 +112,7 @@ class MemcachedDriver extends AbstractDriver {
112 112
 	 * @param int $expires
113 113
 	 * @return DriverInterface
114 114
 	 */
115
-	public function set($key, $value, $expires = 0)
115
+	public function set(string $key, $value, int $expires = 0): DriverInterface
116 116
 	{
117 117
 		if ( ! $this->exists($key))
118 118
 		{
@@ -132,7 +132,7 @@ class MemcachedDriver extends AbstractDriver {
132 132
 	 * @param string $key
133 133
 	 * @return boolean
134 134
 	 */
135
-	public function delete($key)
135
+	public function delete(string $key): bool
136 136
 	{
137 137
 		return $this->conn->delete($key);
138 138
 	}
@@ -143,7 +143,7 @@ class MemcachedDriver extends AbstractDriver {
143 143
 	 * @param string[] $keys
144 144
 	 * @return boolean
145 145
 	 */
146
-	public function deleteMultiple(array $keys = [])
146
+	public function deleteMultiple(array $keys = []): bool
147 147
 	{
148 148
 		return $this->conn->deleteMulti($keys);
149 149
 	}
@@ -153,7 +153,7 @@ class MemcachedDriver extends AbstractDriver {
153 153
 	 *
154 154
 	 * @return boolean
155 155
 	 */
156
-	public function flush()
156
+	public function flush(): bool
157 157
 	{
158 158
 		return $this->conn->flush();
159 159
 	}
@@ -165,7 +165,7 @@ class MemcachedDriver extends AbstractDriver {
165 165
 	 * @param int $expires
166 166
 	 * @return boolean
167 167
 	 */
168
-	public function expiresAt($key, $expires)
168
+	public function expiresAt(string $key, int $expires): bool
169 169
 	{
170 170
 		if ($this->exists($key))
171 171
 		{

+ 11
- 11
src/Driver/NullDriver.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -55,9 +55,9 @@ class NullDriver extends AbstractDriver {
55 55
 	 * @param string $key
56 56
 	 * @return bool
57 57
 	 */
58
-	public function exists($key)
58
+	public function exists(string $key): bool
59 59
 	{
60
-		return \array_key_exists($key, $this->store);
60
+		return array_key_exists($key, $this->store);
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,7 +66,7 @@ class NullDriver extends AbstractDriver {
66 66
 	 * @param string $key
67 67
 	 * @return mixed
68 68
 	 */
69
-	public function get($key)
69
+	public function get(string $key)
70 70
 	{
71 71
 		return ($this->exists($key))
72 72
 			? $this->store[$key]
@@ -79,7 +79,7 @@ class NullDriver extends AbstractDriver {
79 79
 	 * @param string[] $keys
80 80
 	 * @return array
81 81
 	 */
82
-	public function getMultiple(array $keys = [])
82
+	public function getMultiple(array $keys = []): array
83 83
 	{
84 84
 		$output = [];
85 85
 
@@ -99,7 +99,7 @@ class NullDriver extends AbstractDriver {
99 99
 	 * @param int $expires
100 100
 	 * @return DriverInterface
101 101
 	 */
102
-	public function set($key, $value, $expires = 0)
102
+	public function set(string $key, $value, int $expires = 0): DriverInterface
103 103
 	{
104 104
 		$this->store[$key] = $value;
105 105
 		return $this;
@@ -111,7 +111,7 @@ class NullDriver extends AbstractDriver {
111 111
 	 * @param string $key
112 112
 	 * @return boolean
113 113
 	 */
114
-	public function delete($key)
114
+	public function delete(string $key): bool
115 115
 	{
116 116
 		unset($this->store[$key]);
117 117
 		return ( ! array_key_exists($key, $this->store));
@@ -123,7 +123,7 @@ class NullDriver extends AbstractDriver {
123 123
 	 * @param string[] $keys
124 124
 	 * @return boolean
125 125
 	 */
126
-	public function deleteMultiple(array $keys = [])
126
+	public function deleteMultiple(array $keys = []): bool
127 127
 	{
128 128
 		$res = TRUE;
129 129
 
@@ -140,7 +140,7 @@ class NullDriver extends AbstractDriver {
140 140
 	 *
141 141
 	 * @return boolean
142 142
 	 */
143
-	public function flush()
143
+	public function flush(): bool
144 144
 	{
145 145
 		$this->store = [];
146 146
 		return TRUE;
@@ -153,7 +153,7 @@ class NullDriver extends AbstractDriver {
153 153
 	 * @param int $expires
154 154
 	 * @return boolean
155 155
 	 */
156
-	public function expiresAt($key, $expires)
156
+	public function expiresAt(string $key, int $expires): bool
157 157
 	{
158 158
 		//noop
159 159
 		return TRUE;

+ 14
- 14
src/Driver/RedisDriver.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -64,7 +64,7 @@ class RedisDriver extends AbstractDriver {
64 64
 	 * @param string $key
65 65
 	 * @return bool
66 66
 	 */
67
-	public function exists($key)
67
+	public function exists(string $key): bool
68 68
 	{
69 69
 		return (bool) $this->conn->exists($key);
70 70
 	}
@@ -75,10 +75,10 @@ class RedisDriver extends AbstractDriver {
75 75
 	 * @param string $key
76 76
 	 * @return mixed
77 77
 	 */
78
-	public function get($key)
78
+	public function get(string $key)
79 79
 	{
80 80
 		$raw = $this->conn->get($key);
81
-		return \unserialize($raw);
81
+		return unserialize($raw);
82 82
 	}
83 83
 
84 84
 	/**
@@ -87,7 +87,7 @@ class RedisDriver extends AbstractDriver {
87 87
 	 * @param string[] $keys
88 88
 	 * @return array
89 89
 	 */
90
-	public function getMultiple(array $keys = [])
90
+	public function getMultiple(array $keys = []): array
91 91
 	{
92 92
 		$output = [];
93 93
 
@@ -107,9 +107,9 @@ class RedisDriver extends AbstractDriver {
107 107
 	 * @param int $expires
108 108
 	 * @return DriverInterface
109 109
 	 */
110
-	public function set($key, $value, $expires = 0)
110
+	public function set(string $key, $value, int $expires = 0): DriverInterface
111 111
 	{
112
-		$value = \serialize($value);
112
+		$value = serialize($value);
113 113
 
114 114
 		if ($expires !== 0)
115 115
 		{
@@ -129,7 +129,7 @@ class RedisDriver extends AbstractDriver {
129 129
 	 * @param string $key
130 130
 	 * @return boolean
131 131
 	 */
132
-	public function delete($key)
132
+	public function delete(string $key): bool
133 133
 	{
134 134
 		return (bool) $this->conn->del($key);
135 135
 	}
@@ -140,9 +140,9 @@ class RedisDriver extends AbstractDriver {
140 140
 	 * @param string[] $keys
141 141
 	 * @return boolean
142 142
 	 */
143
-	public function deleteMultiple(array $keys = [])
143
+	public function deleteMultiple(array $keys = []): bool
144 144
 	{
145
-		$res = \call_user_func_array([$this->conn, 'del'], $keys);
145
+		$res = call_user_func_array([$this->conn, 'del'], $keys);
146 146
 		return $res === count($keys);
147 147
 	}
148 148
 
@@ -151,9 +151,9 @@ class RedisDriver extends AbstractDriver {
151 151
 	 *
152 152
 	 * @return boolean
153 153
 	 */
154
-	public function flush()
154
+	public function flush(): bool
155 155
 	{
156
-		return $this->conn->flushdb();
156
+		return (bool) $this->conn->flushdb();
157 157
 	}
158 158
 
159 159
 	/**
@@ -163,7 +163,7 @@ class RedisDriver extends AbstractDriver {
163 163
 	 * @param int $expires
164 164
 	 * @return boolean
165 165
 	 */
166
-	public function expiresAt($key, $expires)
166
+	public function expiresAt(string $key, int $expires): bool
167 167
 	{
168 168
 		return (bool) $this->conn->expireat($key, $expires);
169 169
 	}

+ 2
- 2
src/Exception/CacheException.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>

+ 4
- 4
src/Exception/InvalidArgumentException.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -25,7 +25,7 @@ use Psr\Cache\InvalidArgumentException as InvalidArgumentExceptionInterface;
25 25
  * exception class which implements Psr\Cache\InvalidArgumentException.
26 26
  */
27 27
 class InvalidArgumentException extends CacheException implements InvalidArgumentExceptionInterface {
28
-	
28
+
29 29
 	/**
30 30
 	 * Constructor
31 31
 	 *
@@ -33,7 +33,7 @@ class InvalidArgumentException extends CacheException implements InvalidArgument
33 33
 	 * @param int $code
34 34
 	 * @param \Exception $previous
35 35
 	 */
36
-	public function __construct($message = "Cache key must be a string.", $code = 0, \Exception $previous = NULL)
36
+	public function __construct(string $message = "Cache key must be a string.", int $code = 0, \Exception $previous = NULL)
37 37
 	{
38 38
 		parent::__construct($message, $code, $previous);
39 39
 	}

+ 11
- 11
src/Item.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -81,7 +81,7 @@ class Item implements CacheItemInterface {
81 81
 	 * @return string
82 82
 	 *   The key string for this cache item.
83 83
 	 */
84
-	public function getKey()
84
+	public function getKey(): string
85 85
 	{
86 86
 		return $this->key;
87 87
 	}
@@ -117,7 +117,7 @@ class Item implements CacheItemInterface {
117 117
 	 * @return bool
118 118
 	 *   True if the request resulted in a cache hit. False otherwise.
119 119
 	 */
120
-	public function isHit()
120
+	public function isHit(): bool
121 121
 	{
122 122
 		return $this->driver->exists($this->key);
123 123
 	}
@@ -132,10 +132,10 @@ class Item implements CacheItemInterface {
132 132
 	 * @param mixed $value
133 133
 	 *   The serializable value to be stored.
134 134
 	 *
135
-	 * @return static
135
+	 * @return Item
136 136
 	 *   The invoked object.
137 137
 	 */
138
-	public function set($value)
138
+	public function set($value): Item
139 139
 	{
140 140
 		$this->value = $value;
141 141
 		return $this;
@@ -150,10 +150,10 @@ class Item implements CacheItemInterface {
150 150
 	 *   the value should be stored permanently or for as long as the
151 151
 	 *   implementation allows.
152 152
 	 *
153
-	 * @return static
153
+	 * @return Item
154 154
 	 *   The called object.
155 155
 	 */
156
-	public function expiresAt($expiration = NULL)
156
+	public function expiresAt($expiration = NULL): Item
157 157
 	{
158 158
 		if ($expiration instanceof \DateTimeInterface)
159 159
 		{
@@ -175,10 +175,10 @@ class Item implements CacheItemInterface {
175 175
 	 *   If none is set, the value should be stored permanently or for as long as the
176 176
 	 *   implementation allows.
177 177
 	 *
178
-	 * @return static
178
+	 * @return Item
179 179
 	 *   The called object.
180 180
 	 */
181
-	public function expiresAfter($time = NULL)
181
+	public function expiresAfter($time = NULL): Item
182 182
 	{
183 183
 		if ($time instanceof \DateInterval)
184 184
 		{
@@ -194,7 +194,7 @@ class Item implements CacheItemInterface {
194 194
 	 *
195 195
 	 * @return bool
196 196
 	 */
197
-	public function save()
197
+	public function save(): bool
198 198
 	{
199 199
 		if ($this->expiresAt !== NULL && $this->expiresAt !== 0)
200 200
 		{

+ 2
- 2
src/ItemCollection.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>

+ 15
- 17
src/LoggerTrait.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -16,24 +16,22 @@
16 16
 
17 17
 namespace Aviat\Banker;
18 18
 
19
-use Psr\Log\LoggerInterface;
20
-use Psr\Log\LogLevel;
21
-use Psr\Log\NullLogger;
19
+use Psr\Log\{
20
+	LoggerAwareTrait,
21
+	LoggerInterface,
22
+	LogLevel,
23
+	NullLogger
24
+};
22 25
 
23 26
 /**
24 27
  * Trait for keeping track of logger objects
25 28
  */
26 29
 trait LoggerTrait {
27
-	
28
-	/**
29
-	 * Logger instance to use
30
-	 *
31
-	 * @var LoggerInterface
32
-	 */
33
-	protected $logger = NULL;
34
-	
30
+
31
+	use LoggerAwareTrait;
32
+
35 33
 	/**
36
-	 * Return the existing logger instance or 
34
+	 * Return the existing logger instance or
37 35
 	 * a NullLogger, if no instance set
38 36
 	 *
39 37
 	 * @return LoggerInterface
@@ -46,7 +44,7 @@ trait LoggerTrait {
46 44
 		}
47 45
 		return $this->logger;
48 46
 	}
49
-	
47
+
50 48
 	/**
51 49
 	 * Set a logger to keep track of errors
52 50
 	 *
@@ -56,13 +54,13 @@ trait LoggerTrait {
56 54
 	public function setLogger(LoggerInterface $logger)
57 55
 	{
58 56
 		$this->logger = $logger;
59
-		
57
+
60 58
 		// Set the logger for the current driver too
61 59
 		if (isset($this->driver))
62 60
 		{
63 61
 			$this->driver->setLogger($logger);
64 62
 		}
65
-		
63
+
66 64
 		return $this;
67 65
 	}
68 66
 }

+ 13
- 17
src/Pool.php View File

@@ -1,10 +1,10 @@
1
-<?php
1
+<?php declare(strict_types=1);
2 2
 /**
3 3
  * Banker
4 4
  *
5 5
  * A Caching library implementing psr/cache
6 6
  *
7
- * PHP version 5.6
7
+ * PHP version 7.0
8 8
  *
9 9
  * @package     Banker
10 10
  * @author      Timothy J. Warren <tim@timshomepage.net>
@@ -16,15 +16,11 @@
16 16
 
17 17
 namespace Aviat\Banker;
18 18
 
19
-use Psr\Cache\CacheItemInterface;
20
-use Psr\Cache\CacheItemPoolInterface;
21
-use Psr\Log\LoggerAwareInterface;
22
-use Psr\Log\LoggerInterface;
23
-
24 19
 use Aviat\Banker\Driver\DriverInterface;
25 20
 use Aviat\Banker\Exception\InvalidArgumentException;
26
-use Aviat\Banker\Item;
27
-use Aviat\Banker\ItemCollection;
21
+use Aviat\Banker\{Item, ItemCollection};
22
+use Psr\Cache\{CacheItemInterface, CacheItemPoolInterface};
23
+use Psr\Log\{LoggerAwareInterface, LoggerInterface};
28 24
 
29 25
 /**
30 26
  * The main cache manager
@@ -78,7 +74,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
78 74
 	 * @return CacheItemInterface
79 75
 	 *   The corresponding Cache Item.
80 76
 	 */
81
-	public function getItem($key)
77
+	public function getItem($key): CacheItemInterface
82 78
 	{
83 79
 		if ( ! is_string($key))
84 80
 		{
@@ -183,7 +179,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
183 179
 	 * @return bool
184 180
 	 *   True if the pool was successfully cleared. False if there was an error.
185 181
 	 */
186
-	public function clear()
182
+	public function clear(): bool
187 183
 	{
188 184
 		return $this->driver->flush();
189 185
 	}
@@ -201,7 +197,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
201 197
 	 * @return bool
202 198
 	 *   True if the item was successfully removed. False if there was an error.
203 199
 	 */
204
-	public function deleteItem($key)
200
+	public function deleteItem($key): bool
205 201
 	{
206 202
 		if ( ! is_string($key))
207 203
 		{
@@ -231,7 +227,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
231 227
 	 * @return bool
232 228
 	 *   True if the items were successfully removed. False if there was an error.
233 229
 	 */
234
-	public function deleteItems(array $keys)
230
+	public function deleteItems(array $keys): bool
235 231
 	{
236 232
 		foreach ($keys as $key)
237 233
 		{
@@ -253,7 +249,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
253 249
 	 * @return bool
254 250
 	 *   True if the item was successfully persisted. False if there was an error.
255 251
 	 */
256
-	public function save(CacheItemInterface $item)
252
+	public function save(CacheItemInterface $item): bool
257 253
 	{
258 254
 		return $item->save();
259 255
 	}
@@ -267,7 +263,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
267 263
 	 * @return bool
268 264
 	 *   False if the item could not be queued or if a commit was attempted and failed. True otherwise.
269 265
 	 */
270
-	public function saveDeferred(CacheItemInterface $item)
266
+	public function saveDeferred(CacheItemInterface $item): bool
271 267
 	{
272 268
 		$this->deferred[$item->getKey()] = $item;
273 269
 		return TRUE;
@@ -279,7 +275,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
279 275
 	 * @return bool
280 276
 	 *   True if all not-yet-saved items were successfully saved or there were none. False otherwise.
281 277
 	 */
282
-	public function commit()
278
+	public function commit(): bool
283 279
 	{
284 280
 		if (empty($this->deferred))
285 281
 		{
@@ -307,7 +303,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
307 303
 	 * @param array $driverConfig
308 304
 	 * @return DriverInterface
309 305
 	 */
310
-	protected function loadDriver(array $driverConfig)
306
+	protected function loadDriver(array $driverConfig): DriverInterface
311 307
 	{
312 308
 		$driver = ucfirst(strtolower($driverConfig['driver']));
313 309
 		$class = __NAMESPACE__ . "\\Driver\\${driver}Driver";

+ 15
- 1
tests/Driver/DriverTestBase.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests\Driver;
4 18
 

+ 15
- 1
tests/Driver/MemcacheDriverTest.php View File

@@ -1,4 +1,18 @@
1
-<?php 
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests\Driver;
4 18
 

+ 15
- 1
tests/Driver/MemcachedDriverTest.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests\Driver;
4 18
 

+ 15
- 1
tests/Driver/NullDriverTest.php View File

@@ -1,4 +1,18 @@
1
-<?php 
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests\Driver;
4 18
 

+ 15
- 1
tests/Driver/RedisDriverTest.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests\Driver;
4 18
 

+ 15
- 1
tests/Friend.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests;
4 18
 

+ 15
- 1
tests/ItemCollectionTest.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests;
4 18
 

+ 15
- 1
tests/ItemTest.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests;
4 18
 

+ 15
- 1
tests/PoolTest.php View File

@@ -1,4 +1,18 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
2 16
 
3 17
 namespace Aviat\Banker\Tests;
4 18
 

+ 17
- 1
tests/bootstrap.php View File

@@ -1,4 +1,20 @@
1
-<?php
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Banker
4
+ *
5
+ * A Caching library implementing psr/cache
6
+ *
7
+ * PHP version 7.0
8
+ *
9
+ * @package     Banker
10
+ * @author      Timothy J. Warren <tim@timshomepage.net>
11
+ * @copyright   2016  Timothy J. Warren
12
+ * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
+ * @version     1.0.0
14
+ * @link        https://git.timshomepage.net/timw4mail/banker
15
+ */
16
+
17
+namespace Aviat\Banker\Tests;
2 18
 
3 19
 // Autoload test dependencies
4 20
 require __DIR__ . '/../vendor/autoload.php';