From d696a67b6f25a5ed95657f002fe97f417afeb926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Wed, 13 May 2020 13:58:44 +0800 Subject: [PATCH] Optimized code of async-queue, cache, command, config --- .travis.yml | 5 ++++- src/cache/src/Aspect/CacheableAspect.php | 3 +-- src/cache/src/Aspect/FailCacheAspect.php | 3 +-- src/cache/src/Driver/CoroutineMemoryDriver.php | 4 ++++ src/cache/src/Driver/RedisDriver.php | 2 +- src/command/src/Command.php | 2 +- src/database/src/Commands/ModelCommand.php | 3 ++- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index f796b9c60..829bdf276 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,9 @@ before_script: script: - composer analyse \ src/amqp \ - src/async-queue + src/async-queue \ + src/cache \ + src/command \ + src/config - composer test -- --exclude-group NonCoroutine - vendor/bin/phpunit --group NonCoroutine diff --git a/src/cache/src/Aspect/CacheableAspect.php b/src/cache/src/Aspect/CacheableAspect.php index 3129ab9ef..eebe0554f 100644 --- a/src/cache/src/Aspect/CacheableAspect.php +++ b/src/cache/src/Aspect/CacheableAspect.php @@ -18,7 +18,6 @@ use Hyperf\Cache\Driver\KeyCollectorInterface; use Hyperf\Di\Annotation\Aspect; use Hyperf\Di\Aop\AbstractAspect; use Hyperf\Di\Aop\ProceedingJoinPoint; -use Psr\Container\ContainerInterface; /** * @Aspect @@ -32,7 +31,7 @@ class CacheableAspect extends AbstractAspect ]; /** - * @var ContainerInterface + * @var CacheManager */ protected $manager; diff --git a/src/cache/src/Aspect/FailCacheAspect.php b/src/cache/src/Aspect/FailCacheAspect.php index ffd5fe163..3506586ba 100644 --- a/src/cache/src/Aspect/FailCacheAspect.php +++ b/src/cache/src/Aspect/FailCacheAspect.php @@ -18,7 +18,6 @@ use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Di\Annotation\Aspect; use Hyperf\Di\Aop\AbstractAspect; use Hyperf\Di\Aop\ProceedingJoinPoint; -use Psr\Container\ContainerInterface; /** * @Aspect @@ -32,7 +31,7 @@ class FailCacheAspect extends AbstractAspect ]; /** - * @var ContainerInterface + * @var CacheManager */ protected $manager; diff --git a/src/cache/src/Driver/CoroutineMemoryDriver.php b/src/cache/src/Driver/CoroutineMemoryDriver.php index 039d992cb..f60c599f7 100644 --- a/src/cache/src/Driver/CoroutineMemoryDriver.php +++ b/src/cache/src/Driver/CoroutineMemoryDriver.php @@ -51,6 +51,8 @@ class CoroutineMemoryDriver extends Driver implements KeyCollectorInterface foreach ($values as $key => $value) { $this->set($key, $values, $ttl); } + + return true; } public function deleteMultiple($keys) @@ -58,6 +60,8 @@ class CoroutineMemoryDriver extends Driver implements KeyCollectorInterface foreach ($keys as $key) { $this->delete($key); } + + return true; } public function has($key) diff --git a/src/cache/src/Driver/RedisDriver.php b/src/cache/src/Driver/RedisDriver.php index d0cc8b3a8..6409bd17c 100644 --- a/src/cache/src/Driver/RedisDriver.php +++ b/src/cache/src/Driver/RedisDriver.php @@ -113,7 +113,7 @@ class RedisDriver extends Driver implements KeyCollectorInterface return $this->getCacheKey($key); }, $keys); - return $this->redis->del(...$cacheKeys); + return (bool) $this->redis->del(...$cacheKeys); } public function has($key) diff --git a/src/command/src/Command.php b/src/command/src/Command.php index 49a478bb5..e00665880 100644 --- a/src/command/src/Command.php +++ b/src/command/src/Command.php @@ -40,7 +40,7 @@ abstract class Command extends SymfonyCommand protected $input; /** - * @var OutputInterface|SymfonyStyle + * @var SymfonyStyle */ protected $output; diff --git a/src/database/src/Commands/ModelCommand.php b/src/database/src/Commands/ModelCommand.php index 5bf05c3ac..5751751fa 100644 --- a/src/database/src/Commands/ModelCommand.php +++ b/src/database/src/Commands/ModelCommand.php @@ -28,6 +28,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class ModelCommand extends Command { @@ -57,7 +58,7 @@ class ModelCommand extends Command protected $printer; /** - * @var OutputInterface + * @var SymfonyStyle */ protected $output;