PHP 7 or bust!
This commit is contained in:
parent
d63dbdbca3
commit
4f6ae064da
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
if ( ! function_exists('glob_recursive'))
|
||||
{
|
||||
// Does not support flag GLOB_BRACE
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -12,3 +12,4 @@
|
||||
* @version 1.0.0
|
||||
* @link https://git.timshomepage.net/timw4mail/banker
|
||||
*/
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
$file_patterns = [
|
||||
'src/*.php'
|
||||
'src/*.php',
|
||||
'tests/*.php'
|
||||
];
|
||||
|
||||
if ( ! function_exists('glob_recursive'))
|
||||
@ -23,21 +24,30 @@ if ( ! function_exists('glob_recursive'))
|
||||
|
||||
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
|
||||
// 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";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function get_tokens($source)
|
||||
@ -54,7 +64,7 @@ function replace_files(array $files, $template)
|
||||
$text_to_replace = get_text_to_replace($tokens);
|
||||
|
||||
$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);
|
||||
file_put_contents($file, $new_source);
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @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
|
||||
* @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\Driver;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -24,10 +24,10 @@ interface DriverInterface {
|
||||
/**
|
||||
* See if a key exists in the cache
|
||||
*
|
||||
* @param $key
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key);
|
||||
public function exists(string $key): bool;
|
||||
|
||||
/**
|
||||
* Set a cached value
|
||||
@ -37,7 +37,7 @@ interface DriverInterface {
|
||||
* @param int $expires
|
||||
* @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
|
||||
@ -45,7 +45,7 @@ interface DriverInterface {
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key);
|
||||
public function get(string $key);
|
||||
|
||||
/**
|
||||
* Retrieve a set of values by their cache key
|
||||
@ -53,7 +53,7 @@ interface DriverInterface {
|
||||
* @param string[] $keys
|
||||
* @return array
|
||||
*/
|
||||
public function getMultiple(array $keys = []);
|
||||
public function getMultiple(array $keys = []): array;
|
||||
|
||||
/**
|
||||
* Remove an item from the cache
|
||||
@ -61,7 +61,7 @@ interface DriverInterface {
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($key);
|
||||
public function delete(string $key): bool;
|
||||
|
||||
/**
|
||||
* Remove multiple items from the cache
|
||||
@ -69,14 +69,14 @@ interface DriverInterface {
|
||||
* @param string[] $keys
|
||||
* @return boolean
|
||||
*/
|
||||
public function deleteMultiple(array $keys = []);
|
||||
public function deleteMultiple(array $keys = []): bool;
|
||||
|
||||
/**
|
||||
* Empty the cache
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function flush();
|
||||
public function flush(): bool;
|
||||
|
||||
/**
|
||||
* Set the specified key to expire at the given time
|
||||
@ -85,5 +85,5 @@ interface DriverInterface {
|
||||
* @param int $expires
|
||||
* @return boolean
|
||||
*/
|
||||
public function expiresAt($key, $expires);
|
||||
public function expiresAt(string $key, int $expires): bool;
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -43,7 +43,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
|
||||
$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
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key)
|
||||
public function exists(string $key): bool
|
||||
{
|
||||
return $this->conn->get($key) !== FALSE;
|
||||
}
|
||||
@ -71,7 +71,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
public function get(string $key)
|
||||
{
|
||||
return $this->conn->get($key);
|
||||
}
|
||||
@ -82,7 +82,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return array
|
||||
*/
|
||||
public function getMultiple(array $keys = [])
|
||||
public function getMultiple(array $keys = []): array
|
||||
{
|
||||
return $this->conn->get($keys);
|
||||
}
|
||||
@ -95,7 +95,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
* @param int $expires
|
||||
* @return DriverInterface
|
||||
*/
|
||||
public function set($key, $value, $expires = 0)
|
||||
public function set(string $key, $value, int $expires = 0): DriverInterface
|
||||
{
|
||||
if ($this->exists($key))
|
||||
{
|
||||
@ -115,7 +115,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($key)
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
return $this->conn->delete($key);
|
||||
}
|
||||
@ -126,7 +126,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return boolean
|
||||
*/
|
||||
public function deleteMultiple(array $keys = [])
|
||||
public function deleteMultiple(array $keys = []): bool
|
||||
{
|
||||
// Iteratively delete each item, using a boolean
|
||||
// 'and' operation to return false if any deletion fails
|
||||
@ -140,7 +140,7 @@ class MemcacheDriver extends AbstractDriver {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function flush()
|
||||
public function flush(): bool
|
||||
{
|
||||
return $this->conn->flush();
|
||||
}
|
||||
@ -150,13 +150,15 @@ class MemcacheDriver extends AbstractDriver {
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $expires
|
||||
* @return DriverInterface
|
||||
* @return boolean
|
||||
*/
|
||||
public function expiresAt($key, $expires)
|
||||
public function expiresAt(string $key, int $expires): bool
|
||||
{
|
||||
$value = $this->get($key);
|
||||
$timediff = $expires - time();
|
||||
|
||||
return $this->set($key, $value, $timediff);
|
||||
$this->set($key, $value, $timediff);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -46,7 +46,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
{
|
||||
$this->conn = new Memcached();
|
||||
$this->conn->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
|
||||
$this->conn->addServer($config['host'], $config['port']);
|
||||
$this->conn->addServer($config['host'], (int) $config['port']);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if ( ! empty($options))
|
||||
@ -77,7 +77,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key)
|
||||
public function exists(string $key): bool
|
||||
{
|
||||
return $this->conn->get($key) !== FALSE;
|
||||
}
|
||||
@ -88,7 +88,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
public function get(string $key)
|
||||
{
|
||||
return $this->conn->get($key);
|
||||
}
|
||||
@ -99,7 +99,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return array
|
||||
*/
|
||||
public function getMultiple(array $keys = [])
|
||||
public function getMultiple(array $keys = []): array
|
||||
{
|
||||
return $this->conn->getMulti($keys);
|
||||
}
|
||||
@ -112,7 +112,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param int $expires
|
||||
* @return DriverInterface
|
||||
*/
|
||||
public function set($key, $value, $expires = 0)
|
||||
public function set(string $key, $value, int $expires = 0): DriverInterface
|
||||
{
|
||||
if ( ! $this->exists($key))
|
||||
{
|
||||
@ -132,7 +132,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($key)
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
return $this->conn->delete($key);
|
||||
}
|
||||
@ -143,7 +143,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return boolean
|
||||
*/
|
||||
public function deleteMultiple(array $keys = [])
|
||||
public function deleteMultiple(array $keys = []): bool
|
||||
{
|
||||
return $this->conn->deleteMulti($keys);
|
||||
}
|
||||
@ -153,7 +153,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function flush()
|
||||
public function flush(): bool
|
||||
{
|
||||
return $this->conn->flush();
|
||||
}
|
||||
@ -165,7 +165,7 @@ class MemcachedDriver extends AbstractDriver {
|
||||
* @param int $expires
|
||||
* @return boolean
|
||||
*/
|
||||
public function expiresAt($key, $expires)
|
||||
public function expiresAt(string $key, int $expires): bool
|
||||
{
|
||||
if ($this->exists($key))
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -55,9 +55,9 @@ class NullDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @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
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
public function get(string $key)
|
||||
{
|
||||
return ($this->exists($key))
|
||||
? $this->store[$key]
|
||||
@ -79,7 +79,7 @@ class NullDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return array
|
||||
*/
|
||||
public function getMultiple(array $keys = [])
|
||||
public function getMultiple(array $keys = []): array
|
||||
{
|
||||
$output = [];
|
||||
|
||||
@ -99,7 +99,7 @@ class NullDriver extends AbstractDriver {
|
||||
* @param int $expires
|
||||
* @return DriverInterface
|
||||
*/
|
||||
public function set($key, $value, $expires = 0)
|
||||
public function set(string $key, $value, int $expires = 0): DriverInterface
|
||||
{
|
||||
$this->store[$key] = $value;
|
||||
return $this;
|
||||
@ -111,7 +111,7 @@ class NullDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($key)
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
unset($this->store[$key]);
|
||||
return ( ! array_key_exists($key, $this->store));
|
||||
@ -123,7 +123,7 @@ class NullDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return boolean
|
||||
*/
|
||||
public function deleteMultiple(array $keys = [])
|
||||
public function deleteMultiple(array $keys = []): bool
|
||||
{
|
||||
$res = TRUE;
|
||||
|
||||
@ -140,7 +140,7 @@ class NullDriver extends AbstractDriver {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function flush()
|
||||
public function flush(): bool
|
||||
{
|
||||
$this->store = [];
|
||||
return TRUE;
|
||||
@ -153,7 +153,7 @@ class NullDriver extends AbstractDriver {
|
||||
* @param int $expires
|
||||
* @return boolean
|
||||
*/
|
||||
public function expiresAt($key, $expires)
|
||||
public function expiresAt(string $key, int $expires): bool
|
||||
{
|
||||
//noop
|
||||
return TRUE;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -64,7 +64,7 @@ class RedisDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key)
|
||||
public function exists(string $key): bool
|
||||
{
|
||||
return (bool) $this->conn->exists($key);
|
||||
}
|
||||
@ -75,10 +75,10 @@ class RedisDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
public function get(string $key)
|
||||
{
|
||||
$raw = $this->conn->get($key);
|
||||
return \unserialize($raw);
|
||||
return unserialize($raw);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +87,7 @@ class RedisDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @return array
|
||||
*/
|
||||
public function getMultiple(array $keys = [])
|
||||
public function getMultiple(array $keys = []): array
|
||||
{
|
||||
$output = [];
|
||||
|
||||
@ -107,9 +107,9 @@ class RedisDriver extends AbstractDriver {
|
||||
* @param int $expires
|
||||
* @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)
|
||||
{
|
||||
@ -129,7 +129,7 @@ class RedisDriver extends AbstractDriver {
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($key)
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
return (bool) $this->conn->del($key);
|
||||
}
|
||||
@ -140,9 +140,9 @@ class RedisDriver extends AbstractDriver {
|
||||
* @param string[] $keys
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -151,9 +151,9 @@ class RedisDriver extends AbstractDriver {
|
||||
*
|
||||
* @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
|
||||
* @return boolean
|
||||
*/
|
||||
public function expiresAt($key, $expires)
|
||||
public function expiresAt(string $key, int $expires): bool
|
||||
{
|
||||
return (bool) $this->conn->expireat($key, $expires);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -33,7 +33,7 @@ class InvalidArgumentException extends CacheException implements InvalidArgument
|
||||
* @param int $code
|
||||
* @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);
|
||||
}
|
||||
|
22
src/Item.php
22
src/Item.php
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -81,7 +81,7 @@ class Item implements CacheItemInterface {
|
||||
* @return string
|
||||
* The key string for this cache item.
|
||||
*/
|
||||
public function getKey()
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
@ -117,7 +117,7 @@ class Item implements CacheItemInterface {
|
||||
* @return bool
|
||||
* True if the request resulted in a cache hit. False otherwise.
|
||||
*/
|
||||
public function isHit()
|
||||
public function isHit(): bool
|
||||
{
|
||||
return $this->driver->exists($this->key);
|
||||
}
|
||||
@ -132,10 +132,10 @@ class Item implements CacheItemInterface {
|
||||
* @param mixed $value
|
||||
* The serializable value to be stored.
|
||||
*
|
||||
* @return static
|
||||
* @return Item
|
||||
* The invoked object.
|
||||
*/
|
||||
public function set($value)
|
||||
public function set($value): Item
|
||||
{
|
||||
$this->value = $value;
|
||||
return $this;
|
||||
@ -150,10 +150,10 @@ class Item implements CacheItemInterface {
|
||||
* the value should be stored permanently or for as long as the
|
||||
* implementation allows.
|
||||
*
|
||||
* @return static
|
||||
* @return Item
|
||||
* The called object.
|
||||
*/
|
||||
public function expiresAt($expiration = NULL)
|
||||
public function expiresAt($expiration = NULL): Item
|
||||
{
|
||||
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
|
||||
* implementation allows.
|
||||
*
|
||||
* @return static
|
||||
* @return Item
|
||||
* The called object.
|
||||
*/
|
||||
public function expiresAfter($time = NULL)
|
||||
public function expiresAfter($time = NULL): Item
|
||||
{
|
||||
if ($time instanceof \DateInterval)
|
||||
{
|
||||
@ -194,7 +194,7 @@ class Item implements CacheItemInterface {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save()
|
||||
public function save(): bool
|
||||
{
|
||||
if ($this->expiresAt !== NULL && $this->expiresAt !== 0)
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -16,21 +16,19 @@
|
||||
|
||||
namespace Aviat\Banker;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Psr\Log\NullLogger;
|
||||
use Psr\Log\{
|
||||
LoggerAwareTrait,
|
||||
LoggerInterface,
|
||||
LogLevel,
|
||||
NullLogger
|
||||
};
|
||||
|
||||
/**
|
||||
* Trait for keeping track of logger objects
|
||||
*/
|
||||
trait LoggerTrait {
|
||||
|
||||
/**
|
||||
* Logger instance to use
|
||||
*
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
protected $logger = NULL;
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* Return the existing logger instance or
|
||||
|
30
src/Pool.php
30
src/Pool.php
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Banker
|
||||
*
|
||||
* A Caching library implementing psr/cache
|
||||
*
|
||||
* PHP version 5.6
|
||||
* PHP version 7.0
|
||||
*
|
||||
* @package Banker
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
@ -16,15 +16,11 @@
|
||||
|
||||
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\Exception\InvalidArgumentException;
|
||||
use Aviat\Banker\Item;
|
||||
use Aviat\Banker\ItemCollection;
|
||||
use Aviat\Banker\{Item, ItemCollection};
|
||||
use Psr\Cache\{CacheItemInterface, CacheItemPoolInterface};
|
||||
use Psr\Log\{LoggerAwareInterface, LoggerInterface};
|
||||
|
||||
/**
|
||||
* The main cache manager
|
||||
@ -78,7 +74,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return CacheItemInterface
|
||||
* The corresponding Cache Item.
|
||||
*/
|
||||
public function getItem($key)
|
||||
public function getItem($key): CacheItemInterface
|
||||
{
|
||||
if ( ! is_string($key))
|
||||
{
|
||||
@ -183,7 +179,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return bool
|
||||
* True if the pool was successfully cleared. False if there was an error.
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): bool
|
||||
{
|
||||
return $this->driver->flush();
|
||||
}
|
||||
@ -201,7 +197,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return bool
|
||||
* 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))
|
||||
{
|
||||
@ -231,7 +227,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return bool
|
||||
* 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)
|
||||
{
|
||||
@ -253,7 +249,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return bool
|
||||
* 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();
|
||||
}
|
||||
@ -267,7 +263,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return bool
|
||||
* 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;
|
||||
return TRUE;
|
||||
@ -279,7 +275,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @return bool
|
||||
* 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))
|
||||
{
|
||||
@ -307,7 +303,7 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
|
||||
* @param array $driverConfig
|
||||
* @return DriverInterface
|
||||
*/
|
||||
protected function loadDriver(array $driverConfig)
|
||||
protected function loadDriver(array $driverConfig): DriverInterface
|
||||
{
|
||||
$driver = ucfirst(strtolower($driverConfig['driver']));
|
||||
$class = __NAMESPACE__ . "\\Driver\\${driver}Driver";
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
Loading…
Reference in New Issue
Block a user