PHP 7 or bust!

This commit is contained in:
Timothy Warren 2016-10-19 09:57:06 -04:00
parent d63dbdbca3
commit 4f6ae064da
25 changed files with 301 additions and 152 deletions

View File

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

View File

@ -3,7 +3,7 @@
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -12,3 +12,4 @@
* @version 1.0.0 * @version 1.0.0
* @link https://git.timshomepage.net/timw4mail/banker * @link https://git.timshomepage.net/timw4mail/banker
*/ */

View File

@ -1,7 +1,8 @@
<?php <?php
$file_patterns = [ $file_patterns = [
'src/*.php' 'src/*.php',
'tests/*.php'
]; ];
if ( ! function_exists('glob_recursive')) if ( ! function_exists('glob_recursive'))
@ -23,21 +24,30 @@ if ( ! function_exists('glob_recursive'))
function get_text_to_replace($tokens) function get_text_to_replace($tokens)
{ {
if ($tokens[0][0] !== T_OPEN_TAG) $output = '';
// Tokens have the follow structure if arrays:
// [0] => token type constant
// [1] => raw sytax parsed to that token
// [2] => line number
foreach($tokens as $token)
{ {
return NULL; // Since we only care about opening docblocks,
// bail out when we get to the namespace token
if (is_array($token) && $token[0] === T_NAMESPACE)
{
break;
}
if (is_array($token))
{
$token = $token[1];
}
$output .= $token;
} }
// If there is already a docblock, as the second token after the return $output;
// open tag, get the contents of that token to replace
if ($tokens[1][0] === T_DOC_COMMENT)
{
return "<?php\n" . $tokens[1][1];
}
else if ($tokens[1][0] !== T_DOC_COMMENT)
{
return "<?php";
}
} }
function get_tokens($source) function get_tokens($source)
@ -54,7 +64,7 @@ function replace_files(array $files, $template)
$text_to_replace = get_text_to_replace($tokens); $text_to_replace = get_text_to_replace($tokens);
$header = file_get_contents(__DIR__ . $template); $header = file_get_contents(__DIR__ . $template);
$new_text = "<?php\n{$header}"; $new_text = "<?php declare(strict_types=1);\n{$header}";
$new_source = str_replace($text_to_replace, $new_text, $source); $new_source = str_replace($text_to_replace, $new_text, $source);
file_put_contents($file, $new_source); file_put_contents($file, $new_source);

View File

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

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -24,10 +24,10 @@ interface DriverInterface {
/** /**
* See if a key exists in the cache * See if a key exists in the cache
* *
* @param $key * @param string $key
* @return bool * @return bool
*/ */
public function exists($key); public function exists(string $key): bool;
/** /**
* Set a cached value * Set a cached value
@ -37,7 +37,7 @@ interface DriverInterface {
* @param int $expires * @param int $expires
* @return DriverInterface * @return DriverInterface
*/ */
public function set($key, $value, $expires = 0); public function set(string $key, $value, int $expires = 0): DriverInterface;
/** /**
* Get the value for the selected cache key * Get the value for the selected cache key
@ -45,7 +45,7 @@ interface DriverInterface {
* @param string $key * @param string $key
* @return mixed * @return mixed
*/ */
public function get($key); public function get(string $key);
/** /**
* Retrieve a set of values by their cache key * Retrieve a set of values by their cache key
@ -53,7 +53,7 @@ interface DriverInterface {
* @param string[] $keys * @param string[] $keys
* @return array * @return array
*/ */
public function getMultiple(array $keys = []); public function getMultiple(array $keys = []): array;
/** /**
* Remove an item from the cache * Remove an item from the cache
@ -61,7 +61,7 @@ interface DriverInterface {
* @param string $key * @param string $key
* @return boolean * @return boolean
*/ */
public function delete($key); public function delete(string $key): bool;
/** /**
* Remove multiple items from the cache * Remove multiple items from the cache
@ -69,14 +69,14 @@ interface DriverInterface {
* @param string[] $keys * @param string[] $keys
* @return boolean * @return boolean
*/ */
public function deleteMultiple(array $keys = []); public function deleteMultiple(array $keys = []): bool;
/** /**
* Empty the cache * Empty the cache
* *
* @return boolean * @return boolean
*/ */
public function flush(); public function flush(): bool;
/** /**
* Set the specified key to expire at the given time * Set the specified key to expire at the given time
@ -85,5 +85,5 @@ interface DriverInterface {
* @param int $expires * @param int $expires
* @return boolean * @return boolean
*/ */
public function expiresAt($key, $expires); public function expiresAt(string $key, int $expires): bool;
} }

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -43,7 +43,7 @@ class MemcacheDriver extends AbstractDriver {
$method = ($config['persistent'] === TRUE) ? 'pconnect' : 'connect'; $method = ($config['persistent'] === TRUE) ? 'pconnect' : 'connect';
$this->conn->$method($config['host'], $config['port']); $this->conn->$method($config['host'], (int) $config['port']);
} }
/** /**
@ -60,7 +60,7 @@ class MemcacheDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return bool * @return bool
*/ */
public function exists($key) public function exists(string $key): bool
{ {
return $this->conn->get($key) !== FALSE; return $this->conn->get($key) !== FALSE;
} }
@ -71,7 +71,7 @@ class MemcacheDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return mixed * @return mixed
*/ */
public function get($key) public function get(string $key)
{ {
return $this->conn->get($key); return $this->conn->get($key);
} }
@ -82,7 +82,7 @@ class MemcacheDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return array * @return array
*/ */
public function getMultiple(array $keys = []) public function getMultiple(array $keys = []): array
{ {
return $this->conn->get($keys); return $this->conn->get($keys);
} }
@ -95,7 +95,7 @@ class MemcacheDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return DriverInterface * @return DriverInterface
*/ */
public function set($key, $value, $expires = 0) public function set(string $key, $value, int $expires = 0): DriverInterface
{ {
if ($this->exists($key)) if ($this->exists($key))
{ {
@ -115,7 +115,7 @@ class MemcacheDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return boolean * @return boolean
*/ */
public function delete($key) public function delete(string $key): bool
{ {
return $this->conn->delete($key); return $this->conn->delete($key);
} }
@ -126,7 +126,7 @@ class MemcacheDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return boolean * @return boolean
*/ */
public function deleteMultiple(array $keys = []) public function deleteMultiple(array $keys = []): bool
{ {
// Iteratively delete each item, using a boolean // Iteratively delete each item, using a boolean
// 'and' operation to return false if any deletion fails // 'and' operation to return false if any deletion fails
@ -140,7 +140,7 @@ class MemcacheDriver extends AbstractDriver {
* *
* @return boolean * @return boolean
*/ */
public function flush() public function flush(): bool
{ {
return $this->conn->flush(); return $this->conn->flush();
} }
@ -150,13 +150,15 @@ class MemcacheDriver extends AbstractDriver {
* *
* @param string $key * @param string $key
* @param int $expires * @param int $expires
* @return DriverInterface * @return boolean
*/ */
public function expiresAt($key, $expires) public function expiresAt(string $key, int $expires): bool
{ {
$value = $this->get($key); $value = $this->get($key);
$timediff = $expires - time(); $timediff = $expires - time();
return $this->set($key, $value, $timediff); $this->set($key, $value, $timediff);
return TRUE;
} }
} }

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -46,7 +46,7 @@ class MemcachedDriver extends AbstractDriver {
{ {
$this->conn = new Memcached(); $this->conn = new Memcached();
$this->conn->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $this->conn->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$this->conn->addServer($config['host'], $config['port']); $this->conn->addServer($config['host'], (int) $config['port']);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if ( ! empty($options)) if ( ! empty($options))
@ -77,7 +77,7 @@ class MemcachedDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return bool * @return bool
*/ */
public function exists($key) public function exists(string $key): bool
{ {
return $this->conn->get($key) !== FALSE; return $this->conn->get($key) !== FALSE;
} }
@ -88,7 +88,7 @@ class MemcachedDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return mixed * @return mixed
*/ */
public function get($key) public function get(string $key)
{ {
return $this->conn->get($key); return $this->conn->get($key);
} }
@ -99,7 +99,7 @@ class MemcachedDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return array * @return array
*/ */
public function getMultiple(array $keys = []) public function getMultiple(array $keys = []): array
{ {
return $this->conn->getMulti($keys); return $this->conn->getMulti($keys);
} }
@ -112,7 +112,7 @@ class MemcachedDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return DriverInterface * @return DriverInterface
*/ */
public function set($key, $value, $expires = 0) public function set(string $key, $value, int $expires = 0): DriverInterface
{ {
if ( ! $this->exists($key)) if ( ! $this->exists($key))
{ {
@ -132,7 +132,7 @@ class MemcachedDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return boolean * @return boolean
*/ */
public function delete($key) public function delete(string $key): bool
{ {
return $this->conn->delete($key); return $this->conn->delete($key);
} }
@ -143,7 +143,7 @@ class MemcachedDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return boolean * @return boolean
*/ */
public function deleteMultiple(array $keys = []) public function deleteMultiple(array $keys = []): bool
{ {
return $this->conn->deleteMulti($keys); return $this->conn->deleteMulti($keys);
} }
@ -153,7 +153,7 @@ class MemcachedDriver extends AbstractDriver {
* *
* @return boolean * @return boolean
*/ */
public function flush() public function flush(): bool
{ {
return $this->conn->flush(); return $this->conn->flush();
} }
@ -165,7 +165,7 @@ class MemcachedDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return boolean * @return boolean
*/ */
public function expiresAt($key, $expires) public function expiresAt(string $key, int $expires): bool
{ {
if ($this->exists($key)) if ($this->exists($key))
{ {

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -55,9 +55,9 @@ class NullDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return bool * @return bool
*/ */
public function exists($key) public function exists(string $key): bool
{ {
return \array_key_exists($key, $this->store); return array_key_exists($key, $this->store);
} }
/** /**
@ -66,7 +66,7 @@ class NullDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return mixed * @return mixed
*/ */
public function get($key) public function get(string $key)
{ {
return ($this->exists($key)) return ($this->exists($key))
? $this->store[$key] ? $this->store[$key]
@ -79,7 +79,7 @@ class NullDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return array * @return array
*/ */
public function getMultiple(array $keys = []) public function getMultiple(array $keys = []): array
{ {
$output = []; $output = [];
@ -99,7 +99,7 @@ class NullDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return DriverInterface * @return DriverInterface
*/ */
public function set($key, $value, $expires = 0) public function set(string $key, $value, int $expires = 0): DriverInterface
{ {
$this->store[$key] = $value; $this->store[$key] = $value;
return $this; return $this;
@ -111,7 +111,7 @@ class NullDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return boolean * @return boolean
*/ */
public function delete($key) public function delete(string $key): bool
{ {
unset($this->store[$key]); unset($this->store[$key]);
return ( ! array_key_exists($key, $this->store)); return ( ! array_key_exists($key, $this->store));
@ -123,7 +123,7 @@ class NullDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return boolean * @return boolean
*/ */
public function deleteMultiple(array $keys = []) public function deleteMultiple(array $keys = []): bool
{ {
$res = TRUE; $res = TRUE;
@ -140,7 +140,7 @@ class NullDriver extends AbstractDriver {
* *
* @return boolean * @return boolean
*/ */
public function flush() public function flush(): bool
{ {
$this->store = []; $this->store = [];
return TRUE; return TRUE;
@ -153,7 +153,7 @@ class NullDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return boolean * @return boolean
*/ */
public function expiresAt($key, $expires) public function expiresAt(string $key, int $expires): bool
{ {
//noop //noop
return TRUE; return TRUE;

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -64,7 +64,7 @@ class RedisDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return bool * @return bool
*/ */
public function exists($key) public function exists(string $key): bool
{ {
return (bool) $this->conn->exists($key); return (bool) $this->conn->exists($key);
} }
@ -75,10 +75,10 @@ class RedisDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return mixed * @return mixed
*/ */
public function get($key) public function get(string $key)
{ {
$raw = $this->conn->get($key); $raw = $this->conn->get($key);
return \unserialize($raw); return unserialize($raw);
} }
/** /**
@ -87,7 +87,7 @@ class RedisDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return array * @return array
*/ */
public function getMultiple(array $keys = []) public function getMultiple(array $keys = []): array
{ {
$output = []; $output = [];
@ -107,9 +107,9 @@ class RedisDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return DriverInterface * @return DriverInterface
*/ */
public function set($key, $value, $expires = 0) public function set(string $key, $value, int $expires = 0): DriverInterface
{ {
$value = \serialize($value); $value = serialize($value);
if ($expires !== 0) if ($expires !== 0)
{ {
@ -129,7 +129,7 @@ class RedisDriver extends AbstractDriver {
* @param string $key * @param string $key
* @return boolean * @return boolean
*/ */
public function delete($key) public function delete(string $key): bool
{ {
return (bool) $this->conn->del($key); return (bool) $this->conn->del($key);
} }
@ -140,9 +140,9 @@ class RedisDriver extends AbstractDriver {
* @param string[] $keys * @param string[] $keys
* @return boolean * @return boolean
*/ */
public function deleteMultiple(array $keys = []) public function deleteMultiple(array $keys = []): bool
{ {
$res = \call_user_func_array([$this->conn, 'del'], $keys); $res = call_user_func_array([$this->conn, 'del'], $keys);
return $res === count($keys); return $res === count($keys);
} }
@ -151,9 +151,9 @@ class RedisDriver extends AbstractDriver {
* *
* @return boolean * @return boolean
*/ */
public function flush() public function flush(): bool
{ {
return $this->conn->flushdb(); return (bool) $this->conn->flushdb();
} }
/** /**
@ -163,7 +163,7 @@ class RedisDriver extends AbstractDriver {
* @param int $expires * @param int $expires
* @return boolean * @return boolean
*/ */
public function expiresAt($key, $expires) public function expiresAt(string $key, int $expires): bool
{ {
return (bool) $this->conn->expireat($key, $expires); return (bool) $this->conn->expireat($key, $expires);
} }

View File

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

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -33,7 +33,7 @@ class InvalidArgumentException extends CacheException implements InvalidArgument
* @param int $code * @param int $code
* @param \Exception $previous * @param \Exception $previous
*/ */
public function __construct($message = "Cache key must be a string.", $code = 0, \Exception $previous = NULL) public function __construct(string $message = "Cache key must be a string.", int $code = 0, \Exception $previous = NULL)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -81,7 +81,7 @@ class Item implements CacheItemInterface {
* @return string * @return string
* The key string for this cache item. * The key string for this cache item.
*/ */
public function getKey() public function getKey(): string
{ {
return $this->key; return $this->key;
} }
@ -117,7 +117,7 @@ class Item implements CacheItemInterface {
* @return bool * @return bool
* True if the request resulted in a cache hit. False otherwise. * True if the request resulted in a cache hit. False otherwise.
*/ */
public function isHit() public function isHit(): bool
{ {
return $this->driver->exists($this->key); return $this->driver->exists($this->key);
} }
@ -132,10 +132,10 @@ class Item implements CacheItemInterface {
* @param mixed $value * @param mixed $value
* The serializable value to be stored. * The serializable value to be stored.
* *
* @return static * @return Item
* The invoked object. * The invoked object.
*/ */
public function set($value) public function set($value): Item
{ {
$this->value = $value; $this->value = $value;
return $this; return $this;
@ -150,10 +150,10 @@ class Item implements CacheItemInterface {
* the value should be stored permanently or for as long as the * the value should be stored permanently or for as long as the
* implementation allows. * implementation allows.
* *
* @return static * @return Item
* The called object. * The called object.
*/ */
public function expiresAt($expiration = NULL) public function expiresAt($expiration = NULL): Item
{ {
if ($expiration instanceof \DateTimeInterface) if ($expiration instanceof \DateTimeInterface)
{ {
@ -175,10 +175,10 @@ class Item implements CacheItemInterface {
* If none is set, the value should be stored permanently or for as long as the * If none is set, the value should be stored permanently or for as long as the
* implementation allows. * implementation allows.
* *
* @return static * @return Item
* The called object. * The called object.
*/ */
public function expiresAfter($time = NULL) public function expiresAfter($time = NULL): Item
{ {
if ($time instanceof \DateInterval) if ($time instanceof \DateInterval)
{ {
@ -194,7 +194,7 @@ class Item implements CacheItemInterface {
* *
* @return bool * @return bool
*/ */
public function save() public function save(): bool
{ {
if ($this->expiresAt !== NULL && $this->expiresAt !== 0) if ($this->expiresAt !== NULL && $this->expiresAt !== 0)
{ {

View File

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

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -16,21 +16,19 @@
namespace Aviat\Banker; namespace Aviat\Banker;
use Psr\Log\LoggerInterface; use Psr\Log\{
use Psr\Log\LogLevel; LoggerAwareTrait,
use Psr\Log\NullLogger; LoggerInterface,
LogLevel,
NullLogger
};
/** /**
* Trait for keeping track of logger objects * Trait for keeping track of logger objects
*/ */
trait LoggerTrait { trait LoggerTrait {
/** use LoggerAwareTrait;
* Logger instance to use
*
* @var LoggerInterface
*/
protected $logger = NULL;
/** /**
* Return the existing logger instance or * Return the existing logger instance or

View File

@ -1,10 +1,10 @@
<?php <?php declare(strict_types=1);
/** /**
* Banker * Banker
* *
* A Caching library implementing psr/cache * A Caching library implementing psr/cache
* *
* PHP version 5.6 * PHP version 7.0
* *
* @package Banker * @package Banker
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
@ -16,15 +16,11 @@
namespace Aviat\Banker; namespace Aviat\Banker;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Aviat\Banker\Driver\DriverInterface; use Aviat\Banker\Driver\DriverInterface;
use Aviat\Banker\Exception\InvalidArgumentException; use Aviat\Banker\Exception\InvalidArgumentException;
use Aviat\Banker\Item; use Aviat\Banker\{Item, ItemCollection};
use Aviat\Banker\ItemCollection; use Psr\Cache\{CacheItemInterface, CacheItemPoolInterface};
use Psr\Log\{LoggerAwareInterface, LoggerInterface};
/** /**
* The main cache manager * The main cache manager
@ -78,7 +74,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return CacheItemInterface * @return CacheItemInterface
* The corresponding Cache Item. * The corresponding Cache Item.
*/ */
public function getItem($key) public function getItem($key): CacheItemInterface
{ {
if ( ! is_string($key)) if ( ! is_string($key))
{ {
@ -183,7 +179,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return bool * @return bool
* True if the pool was successfully cleared. False if there was an error. * True if the pool was successfully cleared. False if there was an error.
*/ */
public function clear() public function clear(): bool
{ {
return $this->driver->flush(); return $this->driver->flush();
} }
@ -201,7 +197,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return bool * @return bool
* True if the item was successfully removed. False if there was an error. * True if the item was successfully removed. False if there was an error.
*/ */
public function deleteItem($key) public function deleteItem($key): bool
{ {
if ( ! is_string($key)) if ( ! is_string($key))
{ {
@ -231,7 +227,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return bool * @return bool
* True if the items were successfully removed. False if there was an error. * True if the items were successfully removed. False if there was an error.
*/ */
public function deleteItems(array $keys) public function deleteItems(array $keys): bool
{ {
foreach ($keys as $key) foreach ($keys as $key)
{ {
@ -253,7 +249,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return bool * @return bool
* True if the item was successfully persisted. False if there was an error. * True if the item was successfully persisted. False if there was an error.
*/ */
public function save(CacheItemInterface $item) public function save(CacheItemInterface $item): bool
{ {
return $item->save(); return $item->save();
} }
@ -267,7 +263,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return bool * @return bool
* False if the item could not be queued or if a commit was attempted and failed. True otherwise. * False if the item could not be queued or if a commit was attempted and failed. True otherwise.
*/ */
public function saveDeferred(CacheItemInterface $item) public function saveDeferred(CacheItemInterface $item): bool
{ {
$this->deferred[$item->getKey()] = $item; $this->deferred[$item->getKey()] = $item;
return TRUE; return TRUE;
@ -279,7 +275,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @return bool * @return bool
* True if all not-yet-saved items were successfully saved or there were none. False otherwise. * True if all not-yet-saved items were successfully saved or there were none. False otherwise.
*/ */
public function commit() public function commit(): bool
{ {
if (empty($this->deferred)) if (empty($this->deferred))
{ {
@ -307,7 +303,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
* @param array $driverConfig * @param array $driverConfig
* @return DriverInterface * @return DriverInterface
*/ */
protected function loadDriver(array $driverConfig) protected function loadDriver(array $driverConfig): DriverInterface
{ {
$driver = ucfirst(strtolower($driverConfig['driver'])); $driver = ucfirst(strtolower($driverConfig['driver']));
$class = __NAMESPACE__ . "\\Driver\\${driver}Driver"; $class = __NAMESPACE__ . "\\Driver\\${driver}Driver";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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