Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
cexll committed Oct 3, 2022
1 parent 915aaf9 commit eb08f91
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/Aspect/MySqlGrammarAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class MySqlGrammarAspect extends AbstractAspect
'Hyperf\Database\Schema\Grammars\MySqlGrammar::compileColumnListing',
];

public $annotations = [
];
public $annotations = [];

/**
* Compatible with mysql8.
Expand Down
4 changes: 2 additions & 2 deletions src/Aspect/ServiceCacheAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class ServiceCacheAspect extends AbstractAspect
/**
* @var CacheManager
*/
protected $manager;
protected CacheManager $manager;

/**
* @var AnnotationManager
*/
protected $annotationManager;
protected AnnotationManager $annotationManager;

public function __construct(CacheManager $manager, AnnotationManager $annotationManager)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Aspect/ServiceCacheEvictAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class ServiceCacheEvictAspect extends AbstractAspect
/**
* @var CacheManager
*/
protected $manager;
protected CacheManager $manager;

/**
* @var AnnotationManager
*/
protected $annotationManager;
protected AnnotationManager $annotationManager;

public function __construct(CacheManager $manager, AnnotationManager $annotationManager)
{
Expand Down
1 change: 0 additions & 1 deletion src/Command/stubs/Request.stub
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class #REQUEST# extends AbstractRequest
public function rules(): array
{
return [

];
}
}
5 changes: 3 additions & 2 deletions src/Lock/RedisLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function lock(string $name, int $expire = 5, int $retryTimes = 5, int $us
$key = self::REDIS_LOCK_KEY_PREFIX . $name;
while ($retryTimes-- > 0) {
$kVal = microtime(true) + $expire + Coroutine::id();
$lock = (bool) $this->getLock($key, $expire, $kVal); // 上锁
// 上锁
$lock = (bool) $this->getLock($key, $expire, $kVal);
if ($lock) {
$this->lockedNames[$key] = $kVal;
break;
Expand Down Expand Up @@ -74,7 +75,7 @@ public function unlock(string $name): bool
/**
* 获取锁 并执行.
*/
public function run(callable $func, string $name, int $expire = 5, int $retryTimes = 10, int $sleep = 100000)
public function run(callable $func, string $name, int $expire = 5, int $retryTimes = 10, int $sleep = 100000): bool
{
if ($this->lock($name, $expire, $retryTimes, $sleep)) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/CorsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace YogCloud\Framework\Middleware;

use Hyperf\Utils\Context;
use Hyperf\Context\Context;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/JwtAuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class JwtAuthMiddleware extends AuthMiddleware
* Routing Whitelist.
* @var string
*/
protected $authWhiteRoutes;
protected string $authWhiteRoutes;

protected $guards = ['jwt'];

Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/ResponseMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ResponseMiddleware implements MiddlewareInterface
* Routing Whitelist.
* @var string
*/
protected $responseRawRoutes;
protected string $responseRawRoutes;

protected ContainerInterface $container;

Expand Down
2 changes: 1 addition & 1 deletion src/Request/ValidateSceneTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait ValidateSceneTrait
* scene.
* @var string
*/
protected $validateScene;
protected string $validateScene;

/**
* Filter rule scenario.
Expand Down

0 comments on commit eb08f91

Please sign in to comment.