Skip to content

Commit 04f1529

Browse files
committed
Fixes GMP requirement
1 parent a658f4d commit 04f1529

File tree

9 files changed

+30
-8
lines changed

9 files changed

+30
-8
lines changed

phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ parameters:
1919
- '#Parameter \#1 \$value of static method Jose\\Component\\Core\\Util\\BigInteger::createFromGMPResource\(\) expects GMP, resource given\.#'
2020
- '#Return type \(void\) of method Jose\\Bundle\\JoseFramework\\Routing\\JWKSetLoader::getResolver\(\) should be compatible with return type \(Symfony\\Component\\Config\\Loader\\LoaderResolverInterface\) of method Symfony\\Component\\Config\\Loader\\LoaderInterface::getResolver\(\)#'
2121
- '#Instanceof between Jose\\Component\\Core\\JWK and Jose\\Component\\Core\\JWK will always evaluate to true\.#'
22-
- '#Function openssl_pkey_derive not found\.#'
2322
includes:
2423
- vendor/phpstan/phpstan-phpunit/extension.neon
2524
- vendor/phpstan/phpstan-phpunit/rules.neon

src/Component/Encryption/Serializer/JSONFlattenedSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function unserialize(string $input): JWE
9090

9191
private function checkData(?array $data): void
9292
{
93-
if ($data === null || !isset($data['ciphertext']) || isset($data['recipients'])) {
93+
if (null === $data || !isset($data['ciphertext']) || isset($data['recipients'])) {
9494
throw new InvalidArgumentException('Unsupported input.');
9595
}
9696
}

src/Component/Encryption/Serializer/JSONGeneralSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function unserialize(string $input): JWE
9999

100100
private function checkData(?array $data): void
101101
{
102-
if ($data === null || !isset($data['ciphertext']) || !isset($data['recipients'])) {
102+
if (null === $data || !isset($data['ciphertext']) || !isset($data['recipients'])) {
103103
throw new InvalidArgumentException('Unsupported input.');
104104
}
105105
}

src/Component/KeyManagement/Analyzer/ES256KeyAnalyzer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
use Base64Url\Base64Url;
1717
use Jose\Component\Core\JWK;
1818
use Jose\Component\Core\Util\Ecc\NistCurve;
19+
use RuntimeException;
1920

2021
final class ES256KeyAnalyzer implements KeyAnalyzer
2122
{
23+
public function __construct()
24+
{
25+
if (!class_exists(NistCurve::class)) {
26+
throw new RuntimeException('Please install web-token/jwt-util-ecc to use this key analyzer');
27+
}
28+
}
29+
2230
public function analyze(JWK $jwk, MessageBag $bag): void
2331
{
2432
if ('EC' !== $jwk->get('kty')) {

src/Component/KeyManagement/Analyzer/ES384KeyAnalyzer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
use Base64Url\Base64Url;
1717
use Jose\Component\Core\JWK;
1818
use Jose\Component\Core\Util\Ecc\NistCurve;
19+
use RuntimeException;
1920

2021
final class ES384KeyAnalyzer implements KeyAnalyzer
2122
{
23+
public function __construct()
24+
{
25+
if (!class_exists(NistCurve::class)) {
26+
throw new RuntimeException('Please install web-token/jwt-util-ecc to use this key analyzer');
27+
}
28+
}
29+
2230
public function analyze(JWK $jwk, MessageBag $bag): void
2331
{
2432
if ('EC' !== $jwk->get('kty')) {

src/Component/KeyManagement/Analyzer/ES512KeyAnalyzer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
use Base64Url\Base64Url;
1717
use Jose\Component\Core\JWK;
1818
use Jose\Component\Core\Util\Ecc\NistCurve;
19+
use RuntimeException;
1920

2021
final class ES512KeyAnalyzer implements KeyAnalyzer
2122
{
23+
public function __construct()
24+
{
25+
if (!class_exists(NistCurve::class)) {
26+
throw new RuntimeException('Please install web-token/jwt-util-ecc to use this key analyzer');
27+
}
28+
}
29+
2230
public function analyze(JWK $jwk, MessageBag $bag): void
2331
{
2432
if ('EC' !== $jwk->get('kty')) {

src/Component/KeyManagement/composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
},
2222
"require": {
2323
"ext-openssl": "*",
24-
"ext-gmp": "*",
2524
"psr/http-factory": "^1.0",
2625
"psr/http-client": "^1.0",
27-
"web-token/jwt-core": "^2.0",
28-
"web-token/jwt-util-ecc": "^2.0"
26+
"web-token/jwt-core": "^2.0"
2927
},
3028
"require-dev": {
3129
"php-http/message-factory": "^1.0",
@@ -34,6 +32,7 @@
3432
"phpunit/phpunit": "^8.0"
3533
},
3634
"suggest": {
35+
"web-token/jwt-util-ecc": "To use EC key analyzers.",
3736
"php-http/message-factory": "To enable JKU/X5U support.",
3837
"php-http/httplug": "To enable JKU/X5U support."
3938
},

src/Ecc/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121
},
2222
"require": {
23+
"ext-gmp": "*",
2324
"thecodingmachine/safe": "^0.1.14"
2425
},
2526
"require-dev": {

src/SignatureAlgorithm/ECDSA/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
}
2121
},
2222
"require": {
23-
"web-token/jwt-signature": "^2.0",
24-
"web-token/jwt-util-ecc": "^2.0"
23+
"web-token/jwt-signature": "^2.0"
2524
},
2625
"require-dev": {
2726
"phpunit/phpunit": "^8.0"

0 commit comments

Comments
 (0)