From 87e64ee3b559b8daddaa40337f2d00e6775c7887 Mon Sep 17 00:00:00 2001 From: Divine Niiquaye Ibok Date: Wed, 28 Apr 2021 23:56:33 +0000 Subject: [PATCH] Fixed coding standard issues --- phpstan.neon.dist | 10 ++--- psalm.xml.dist | 90 ++++++++++++++--------------------------- src/AdapterFactory.php | 4 +- src/FastCache.php | 13 +----- tests/FastCacheTest.php | 50 +++++++++++------------ 5 files changed, 63 insertions(+), 104 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 91c55fd..b8fc9e6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,7 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon parameters: - level: max + level: 4 paths: [src] treatPhpDocTypesAsCertain: false checkMissingIterableValueType: false @@ -10,8 +10,8 @@ parameters: ignoreErrors: - "#^Construct empty\\(\\) is not allowed. Use more strict comparison.$#" - - message: "#^Cannot call method add\\(\\) on DateTime\\|false.$#" - path: src/CacheItem.php - - - message: "#^Strict comparison using !== between false and true will always evaluate to true.$#" + message: "#^Variable \\$deleteItem might not be defined|Variable method call on Psr\\\\Cache\\\\CacheItemPoolInterface\\|Psr\\\\SimpleCache\\\\CacheInterface.$#" path: src/FastCache.php + - + message: "#^Short ternary operator is not allowed. Use null coalesce operator if applicable or consider using long ternary|Class Symfony\\\\Component\\\\Cache\\\\DoctrineProvider not found.$#" + path: src/AdapterFactory.php diff --git a/psalm.xml.dist b/psalm.xml.dist index 427c6a8..01938cf 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -1,60 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/AdapterFactory.php b/src/AdapterFactory.php index 454a7ab..93ba48b 100644 --- a/src/AdapterFactory.php +++ b/src/AdapterFactory.php @@ -92,7 +92,7 @@ public static function createHandler($connection): CacheItemPoolInterface /** * @param mixed $adapter * - * @return \Redis|\Memcache|\Memcached|DoctrineCache|null + * @return \Redis|\Memcache|\Memcached|DoctrineCache\Cache|null */ private static function getPrefixedAdapter(string $connection, $adapter) { @@ -119,7 +119,7 @@ private static function getPrefixedAdapter(string $connection, $adapter) case 'Memcache': case 'Memcache': - /** @var \Memcache|\Memcached */ + /** @var \Memcache|\Memcached $adapter */ ($adapter = new $connectionServer())->addServer($host, $port ?? 11211); break; diff --git a/src/FastCache.php b/src/FastCache.php index 84b3975..e9f4731 100644 --- a/src/FastCache.php +++ b/src/FastCache.php @@ -98,8 +98,6 @@ public function derive(string $namespace): self /** * Reads the specified item from the cache or generate it. * - * @param mixed $key - * * @return mixed */ public function load(string $key, callable $fallback = null, ?float $beta = null) @@ -152,9 +150,6 @@ static function (CacheItemInterface $item) use ($key, $fallback) { /** * Writes an item into the cache. * - * @param mixed $key - * @param callable|null $callback - * * @return mixed value itself */ public function save(string $key, callable $callback, ?float $beta = null) @@ -172,8 +167,6 @@ public function save(string $key, callable $callback, ?float $beta = null) /** * Remove an item from the cache. - * - * @param mixed $key */ public function delete(string $key): bool { @@ -206,8 +199,6 @@ static function (CacheItemInterface $item) use ($callback, $key) { * * @see {@call} * - * @param float|null $beta - * * @return callable so arguments can be passed into for final results */ public function wrap(callable $callback /* ... arguments passed to $callback */): callable @@ -219,10 +210,8 @@ public function wrap(callable $callback /* ... arguments passed to $callback */) /** * Starts the output cache. - * - * @param mixed $key */ - public function start($key): ?OutputHelper + public function start(string $key): ?OutputHelper { $data = $this->load($key); diff --git a/tests/FastCacheTest.php b/tests/FastCacheTest.php index 9650f6a..8f7e65c 100644 --- a/tests/FastCacheTest.php +++ b/tests/FastCacheTest.php @@ -1,25 +1,25 @@ - - * @copyright 2019 Biurad Group (https://biurad.com/) - * @license https://opensource.org/licenses/BSD-3-Clause License - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Biurad\Cache\Tests; - -use Biurad\Cache\FastCache; -use PHPUnit\Framework\TestCase; - -class FastCacheTest extends TestCase -{ -} + + * @copyright 2019 Biurad Group (https://biurad.com/) + * @license https://opensource.org/licenses/BSD-3-Clause License + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Biurad\Cache\Tests; + +use Biurad\Cache\FastCache; +use PHPUnit\Framework\TestCase; + +class FastCacheTest extends TestCase +{ +}