diff --git a/.gitignore b/.gitignore index 01d169a..9ab55da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ vendor/ composer.lock +/*.rdb ###> squizlabs/php_codesniffer ### /.phpcs-cache diff --git a/DependencyInjection/RedisExtension.php b/DependencyInjection/RedisExtension.php index 1a5b403..b4ff4e4 100644 --- a/DependencyInjection/RedisExtension.php +++ b/DependencyInjection/RedisExtension.php @@ -13,7 +13,7 @@ class RedisExtension extends ConfigurableExtension /** * loadInternal. * - * @param mixed[] $configs + * @param array{clients: array>} $configs * @param ContainerBuilder $container */ protected function loadInternal(array $configs, ContainerBuilder $container): void diff --git a/Redis/Client.php b/Redis/Client.php index db9bab9..cea1f89 100644 --- a/Redis/Client.php +++ b/Redis/Client.php @@ -21,7 +21,9 @@ public function __construct($parameters = null, $options = null) */ public function pop(string $key): ?string { - return $this->call('lpop', [$key]); + $result = $this->call('lpop', [$key]); + + return null === $result ? null : (string) $result; } /** @@ -29,7 +31,7 @@ public function pop(string $key): ?string */ public function push(string $key, ...$values): int { - return $this->call('rpush', array_merge([$key], $values)); + return (int) $this->call('rpush', array_merge([$key], $values)); } /** @@ -37,7 +39,7 @@ public function push(string $key, ...$values): int */ public function count(string $key): int { - return $this->call('llen', [$key]); + return (int) $this->call('llen', [$key]); } /** @@ -45,7 +47,7 @@ public function count(string $key): int */ public function remove(string $key): int { - return $this->call('del', [$key]); + return (int) $this->call('del', [$key]); } /** @@ -54,10 +56,13 @@ public function remove(string $key): int * @param string $command the command ID * @param mixed[] $arguments the arguments for the command * - * @return mixed + * @return int|bool|string|float|null */ protected function call(string $command, array $arguments = []) { - return $this->executeCommand($this->createCommand($command, $arguments)); + /** @var int|bool|string|float|null $result */ + $result = $this->executeCommand($this->createCommand($command, $arguments)); + + return $result; } } diff --git a/Tests/Fixtures/app/AppKernel.php b/Tests/Fixtures/app/AppKernel.php index b3e393c..c1e32e9 100644 --- a/Tests/Fixtures/app/AppKernel.php +++ b/Tests/Fixtures/app/AppKernel.php @@ -45,6 +45,7 @@ public function getLogDir(): string public function registerContainerConfiguration(LoaderInterface $loader): void { + // @phpstan-ignore-next-line if (Kernel::VERSION_ID < 53000) { $loader->load($this->getRootDir() . '/config/config_test.yml'); diff --git a/Tests/Redis/ClientTest.php b/Tests/Redis/ClientTest.php index 5e462e4..2a4987d 100644 --- a/Tests/Redis/ClientTest.php +++ b/Tests/Redis/ClientTest.php @@ -3,6 +3,7 @@ namespace SymfonyBundles\RedisBundle\Tests\Redis; use Exception; +use Predis\Response\Status; use SymfonyBundles\RedisBundle\Tests\TestCase; use SymfonyBundles\RedisBundle\Redis\ClientInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -56,7 +57,9 @@ public function testSingleConnection(): void ], ]); - $this->assertSame('OK', $client->flushall()->getPayload()); + $result = $client->flushall(); + $this->assertInstanceOf(Status::class, $result); + $this->assertSame('OK', $result->getPayload()); } /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6901494..eec6b84 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4,7 +4,3 @@ parameters: message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" count: 1 path: DependencyInjection/Configuration.php - - - message: '#^Comparison operation "<" between 70103 and 53000 is always false.$#' - count: 1 - path: Tests/Fixtures/app/AppKernel.php diff --git a/phpstan.neon b/phpstan.neon index 00ba427..f42a237 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 8 + level: max paths: - DependencyInjection/ - Redis/