From 73b3ad1406496f7871d09abe3cba56f6a8158858 Mon Sep 17 00:00:00 2001 From: Mihail Binev Date: Mon, 3 May 2021 17:41:19 +0200 Subject: [PATCH] - updates and chore --- .travis.yml | 2 +- Cache.php | 6 +----- CacheException.php | 2 +- Client/ClientFactory.php | 4 ++-- Configuration/CacheConfiguration.php | 2 +- Configuration/ConfigFactory.php | 4 ++-- Configuration/MemcachedConfiguration.php | 4 +--- README.md | 4 ++-- functions.php | 2 +- 9 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index a871ea7..15f2fc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ cache: - $HOME/.composer/cache php: - - 8.0 + - 8.0.1 - nightly jobs: diff --git a/Cache.php b/Cache.php index b6ce659..506c4a0 100644 --- a/Cache.php +++ b/Cache.php @@ -27,11 +27,7 @@ interface Cache extends CacheInterface /** * Returns the underlying cache client. * - * @return \Memcached | \Redis - * | \Predis\Client - * | \Koded\Caching\Client\FileClient - * | \Koded\Caching\Client\MemoryClient - * | \Koded\Caching\Client\ShmopClient + * @return \Memcached | \Redis | \Predis\Client | \Koded\Caching\Client\FileClient | \Koded\Caching\Client\MemoryClient | \Koded\Caching\Client\ShmopClient */ public function client(); diff --git a/CacheException.php b/CacheException.php index d6b1ea0..944b6b8 100644 --- a/CacheException.php +++ b/CacheException.php @@ -27,7 +27,7 @@ class CacheException extends KodedException implements InvalidArgumentException public static function forInvalidKey($key): static { - return new static(Cache::E_INVALID_KEY, [':key' => var_export($key, true), ':type' => gettype($key)]); + return new static(Cache::E_INVALID_KEY, [':key' => \var_export($key, true), ':type' => \gettype($key)]); } public static function forUnsupportedLogger(string $supported, string $given): static diff --git a/Client/ClientFactory.php b/Client/ClientFactory.php index 75ebe8e..4d7a235 100644 --- a/Client/ClientFactory.php +++ b/Client/ClientFactory.php @@ -117,7 +117,7 @@ private function newRedisClient(RedisConfiguration $conf): \Redis } /** @noinspection PhpRedundantCatchClauseInspection */ catch (\RedisException $e) { if (!\strpos($e->getMessage(), ' AUTH ')) { - \error_log(sprintf(PHP_EOL . '[Redis] %s: %s', \get_class($e), $e->getMessage())); + \error_log(\sprintf(PHP_EOL . '[Redis] %s: %s', \get_class($e), $e->getMessage())); \error_log('[Redis] with conf: ' . $conf->toJSON()); throw CacheException::withConnectionErrorFor('Redis'); } @@ -141,7 +141,7 @@ private function newPredisClient(PredisConfiguration $conf): \Predis\Client } /** @noinspection PhpRedundantCatchClauseInspection */ catch (\Predis\Connection\ConnectionException $e) { if (!\strpos($e->getMessage(), ' AUTH ')) { - \error_log(sprintf(PHP_EOL . '[Predis] %s: %s', \get_class($e), $e->getMessage())); + \error_log(\sprintf(PHP_EOL . '[Predis] %s: %s', \get_class($e), $e->getMessage())); \error_log('[Predis] with conf: ' . $conf->toJSON()); throw CacheException::withConnectionErrorFor('Predis'); } diff --git a/Configuration/CacheConfiguration.php b/Configuration/CacheConfiguration.php index f8527f5..089f4bc 100644 --- a/Configuration/CacheConfiguration.php +++ b/Configuration/CacheConfiguration.php @@ -17,6 +17,6 @@ abstract class CacheConfiguration extends Config /** @noinspection PhpMissingParentConstructorInspection */ public function __construct(array $parameters = []) { - $parameters and $this->import($parameters); + $parameters && $this->import($parameters); } } diff --git a/Configuration/ConfigFactory.php b/Configuration/ConfigFactory.php index 9d831d8..69a30c2 100644 --- a/Configuration/ConfigFactory.php +++ b/Configuration/ConfigFactory.php @@ -25,7 +25,7 @@ class ConfigFactory extends Config /** @noinspection PhpMissingParentConstructorInspection */ public function __construct(array $parameters = []) { - $parameters and $this->import($parameters); + $parameters && $this->import($parameters); } public function build(string $context): Configuration @@ -37,7 +37,7 @@ public function build(string $context): Configuration } catch (CacheException $e) { throw $e; // @codeCoverageIgnoreEnd - } catch (Throwable $e) { + } catch (Throwable) { return new class($this->toArray()) extends CacheConfiguration {}; } } diff --git a/Configuration/MemcachedConfiguration.php b/Configuration/MemcachedConfiguration.php index e5e64a7..3131e59 100644 --- a/Configuration/MemcachedConfiguration.php +++ b/Configuration/MemcachedConfiguration.php @@ -96,9 +96,7 @@ public function getServers(): array */ public function getOptions(): array { - return \array_filter($this->toArray()['options'], function($value) { - return null !== $value; - }); + return \array_filter($this->toArray()['options'], fn($value) => null !== $value); } /** diff --git a/README.md b/README.md index 9a6546b..4f67cba 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Koded - Simple Caching Library [![Code Coverage](https://scrutinizer-ci.com/g/kodedphp/cache-simple/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/cache-simple/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kodedphp/cache-simple/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/cache-simple/?branch=master) [![Packagist Downloads](https://img.shields.io/packagist/dt/koded/cache-simple.svg)](https://packagist.org/packages/koded/cache-simple) -[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg)](https://php.net/) +[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.0-8892BF.svg)](https://php.net/) -A [PSR-16][10] caching library for PHP7 using several caching technologies. +A [PSR-16][10] caching library for PHP 8 using several caching technologies. It supports JSON caching for Redis. diff --git a/functions.php b/functions.php index 6f0ad1a..92d6ed1 100644 --- a/functions.php +++ b/functions.php @@ -83,7 +83,7 @@ function normalize_ttl(mixed $value): ?int if ($value instanceof DateInterval) { return \date_create('@0', \timezone_open('UTC'))->add($value)->getTimestamp(); } - throw CacheException::generic('Invalid TTL, given ' . var_export($value, true)); + throw CacheException::generic('Invalid TTL, given ' . \var_export($value, true)); } /**