From bbe3d2bce6b9ab04acfd1f3c2dc8e0fed89ba1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=84=E6=9C=88?= <{ID}+{username}@users.noreply.github.com> Date: Wed, 15 Feb 2023 17:33:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index f8bdbbc..0ce908f 100644 --- a/composer.json +++ b/composer.json @@ -32,24 +32,23 @@ } }, "require": { - "php": ">=7.3", - "ext-swoole": ">=4.5", + "php": ">=8.0", "ext-json": "*", "ext-openssl": "*", - "hyperf/cache": "^2.1", - "hyperf/command": "^2.1", - "hyperf/config": "^2.1", - "hyperf/di": "^2.1", - "hyperf/framework": "^2.1", + "hyperf/cache": "~3.0.0", + "hyperf/command": "~3.0.0", + "hyperf/config": "~3.0.0", + "hyperf/di": "~3.0.0", + "hyperf/framework": "~3.0.0", "lcobucci/jwt": "~4.1.0", "nesbot/carbon": "^2.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "hyperf/testing": "^2.1", - "phpstan/phpstan": "^0.12", - "swoole/ide-helper": "dev-master", - "mockery/mockery": "^1.0" + "hyperf/testing": "~3.0.0", + "mockery/mockery": "^1.0", + "phpstan/phpstan": "^1.9", + "swoole/ide-helper": "dev-master" }, "config": { "sort-packages": true From 812d5a087b29fb926334f55b2ebef40b93ec4ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=84=E6=9C=88?= <{ID}+{username}@users.noreply.github.com> Date: Wed, 15 Feb 2023 17:38:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=80=82=E9=85=8Dhyperf3.0=E5=8F=8Aphp8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Claims/Collection.php | 2 +- src/Commands/AbstractGenCommand.php | 2 +- src/Commands/GenJwtKeypairCommand.php | 4 ++-- src/Commands/GenJwtSecretCommand.php | 4 ++-- src/Jwt.php | 2 +- src/Payload.php | 12 ++++++------ 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Claims/Collection.php b/src/Claims/Collection.php index 48f0123..766c316 100644 --- a/src/Claims/Collection.php +++ b/src/Claims/Collection.php @@ -56,7 +56,7 @@ public function validate(bool $ignoreExpired = false) */ public function hasAllClaims($claims): bool { - return count($claims) and (new static($claims))->diff($this->keys())->isEmpty(); + return count($claims) and (new self($claims))->diff($this->keys())->isEmpty(); } /** diff --git a/src/Commands/AbstractGenCommand.php b/src/Commands/AbstractGenCommand.php index 80d9093..77472ab 100644 --- a/src/Commands/AbstractGenCommand.php +++ b/src/Commands/AbstractGenCommand.php @@ -21,7 +21,7 @@ abstract class AbstractGenCommand extends HyperfCommand */ protected $config; - protected $description; + protected string $description; public function __construct(ConfigInterface $config) { diff --git a/src/Commands/GenJwtKeypairCommand.php b/src/Commands/GenJwtKeypairCommand.php index 68afb9b..1cf4b63 100644 --- a/src/Commands/GenJwtKeypairCommand.php +++ b/src/Commands/GenJwtKeypairCommand.php @@ -14,9 +14,9 @@ class GenJwtKeypairCommand extends AbstractGenCommand { - protected $name = 'gen:jwt-keypair'; + protected ?string $name = 'gen:jwt-keypair'; - protected $description = 'Set the JWT private key and public key used to sign the tokens'; + protected string $description = 'Set the JWT private key and public key used to sign the tokens'; protected $configs = [ 'RS256' => ['private_key_type' => OPENSSL_KEYTYPE_RSA, 'digest_alg' => 'SHA256', 'private_key_bits' => 4096], diff --git a/src/Commands/GenJwtSecretCommand.php b/src/Commands/GenJwtSecretCommand.php index dddf156..b8b6227 100644 --- a/src/Commands/GenJwtSecretCommand.php +++ b/src/Commands/GenJwtSecretCommand.php @@ -14,9 +14,9 @@ class GenJwtSecretCommand extends AbstractGenCommand { - protected $name = 'gen:jwt-secret'; + protected ?string $name = 'gen:jwt-secret'; - protected $description = 'Set the JWT secret key used to sign the tokens'; + protected string $description = 'Set the JWT secret key used to sign the tokens'; public function handle() { diff --git a/src/Jwt.php b/src/Jwt.php index 373a5de..8cf13eb 100644 --- a/src/Jwt.php +++ b/src/Jwt.php @@ -11,7 +11,7 @@ namespace HyperfExt\Jwt; use BadMethodCallException; -use Hyperf\Utils\Context; +use Hyperf\Context\Context; use HyperfExt\Jwt\Contracts\JwtSubjectInterface; use HyperfExt\Jwt\Contracts\ManagerInterface; use HyperfExt\Jwt\Contracts\RequestParser\RequestParserInterface; diff --git a/src/Payload.php b/src/Payload.php index ab3d0a5..38948d7 100644 --- a/src/Payload.php +++ b/src/Payload.php @@ -15,8 +15,8 @@ use Countable; use Hyperf\Utils\ApplicationContext; use Hyperf\Utils\Arr; -use Hyperf\Utils\Contracts\Arrayable; -use Hyperf\Utils\Contracts\Jsonable; +use Hyperf\Contract\Arrayable; +use Hyperf\Contract\Jsonable; use HyperfExt\Jwt\Claims\AbstractClaim; use HyperfExt\Jwt\Claims\Collection; use HyperfExt\Jwt\Contracts\PayloadValidatorInterface; @@ -196,7 +196,7 @@ public function toJson(int $options = JSON_UNESCAPED_SLASHES): string * * @param mixed $key */ - public function offsetExists($key): bool + public function offsetExists(mixed $key): bool { return Arr::has($this->toArray(), $key); } @@ -208,7 +208,7 @@ public function offsetExists($key): bool * * @return mixed */ - public function offsetGet($key) + public function offsetGet(mixed $key): mixed { return Arr::get($this->toArray(), $key); } @@ -221,7 +221,7 @@ public function offsetGet($key) * * @throws \HyperfExt\Jwt\Exceptions\PayloadException */ - public function offsetSet($key, $value) + public function offsetSet(mixed $key, mixed $value): void { throw new PayloadException('The payload is immutable'); } @@ -233,7 +233,7 @@ public function offsetSet($key, $value) * * @throws \HyperfExt\Jwt\Exceptions\PayloadException */ - public function offsetUnset($key) + public function offsetUnset(mixed $key): void { throw new PayloadException('The payload is immutable'); } From 4ec2a737a4fe7a6f190b601e02148f7627dea1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=84=E6=9C=88?= <{ID}+{username}@users.noreply.github.com> Date: Wed, 15 Feb 2023 17:44:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/RequestParserTest.php | 2 +- tests/bootstrap.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/RequestParserTest.php b/tests/RequestParserTest.php index 5edf607..607e3ff 100644 --- a/tests/RequestParserTest.php +++ b/tests/RequestParserTest.php @@ -14,7 +14,7 @@ use Hyperf\HttpMessage\Server\Request; use Hyperf\HttpServer\Request as HttpServerRequest; use Hyperf\HttpServer\Router\Dispatched; -use Hyperf\Utils\Context; +use Hyperf\Context\Context; use HyperfExt\Jwt\RequestParser\Handlers\AuthHeaders; use HyperfExt\Jwt\RequestParser\Handlers\Cookies; use HyperfExt\Jwt\RequestParser\Handlers\InputSource; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3b87b8c..c3283f6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -10,14 +10,13 @@ */ use Hyperf\Config\Config; use Hyperf\Contract\ConfigInterface; -use Hyperf\Di\Annotation\AnnotationReader; use Hyperf\Di\ClassLoader; use Hyperf\Di\Container; use Hyperf\Di\Definition\DefinitionSourceFactory; use Hyperf\HttpMessage\Server\Request; use Hyperf\HttpServer\Request as HttpServerRequest; use Hyperf\Utils\ApplicationContext; -use Hyperf\Utils\Context; +use Hyperf\Context\Context; use HyperfExt\Jwt\Contracts\PayloadValidatorInterface; use HyperfExt\Jwt\Contracts\TokenValidatorInterface; use HyperfExt\Jwt\Validators\PayloadValidator; @@ -31,8 +30,6 @@ require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php'; -AnnotationReader::addGlobalIgnoredName('mixin'); - ClassLoader::init(); $container = new Container((new DefinitionSourceFactory(true))());