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 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'); } 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))());