Skip to content

Commit dcc82ec

Browse files
committed
Remove deprecated checks and update test dependencies
The deprecated checks in the UrlKeySetFactory are removed. Slow test detection is added to PHPUnit tests with the Ergebnis\PHPUnit\SlowTestDetector dependency. Several method parameters in tests are also updated for clarity and to reduce cognitive load in parsing the test setup and assertions.
1 parent 85544c0 commit dcc82ec

File tree

7 files changed

+17
-80
lines changed

7 files changed

+17
-80
lines changed

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"ext-gmp": "*",
6767
"ext-sodium": "*",
6868
"ekino/phpstan-banned-code": "^1.0",
69+
"ergebnis/phpunit-slow-test-detector": "^2.14",
6970
"infection/infection": "^0.28",
7071
"matthiasnoback/symfony-config-test": "^5.0",
7172
"paragonie/sodium_compat": "^1.20",
@@ -74,13 +75,18 @@
7475
"phpstan/extension-installer": "^1.3",
7576
"phpstan/phpstan": "^1.8",
7677
"phpstan/phpstan-deprecation-rules": "^1.0",
78+
"phpstan/phpstan-doctrine": "^1.3",
7779
"phpstan/phpstan-phpunit": "^1.1",
7880
"phpstan/phpstan-strict-rules": "^1.4",
81+
"phpstan/phpstan-symfony": "^1.3",
7982
"phpunit/phpunit": "^10.5.10|^11.0",
8083
"qossmic/deptrac-shim": "^1.0",
8184
"rector/rector": "^1.0",
8285
"roave/security-advisories": "dev-latest",
8386
"spomky-labs/aes-key-wrap": "^7.0",
87+
"staabm/phpstan-dba": "^0.2.79",
88+
"staabm/phpstan-todo-by": "^0.1.25",
89+
"struggle-for-php/sfp-phpstan-psr-log": "^0.20.0",
8490
"symfony/browser-kit": "^7.0",
8591
"symfony/clock": "^7.0",
8692
"symfony/finder": "^7.0",

phpstan-baseline.neon

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ parameters:
3535
count: 1
3636
path: src/Bundle/DependencyInjection/JoseFrameworkExtension.php
3737

38-
-
39-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\DependencyInjection\\\\JoseFrameworkExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#"
40-
count: 1
41-
path: src/Bundle/DependencyInjection/JoseFrameworkExtension.php
42-
4338
-
4439
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
4540
count: 1
@@ -890,16 +885,6 @@ parameters:
890885
count: 1
891886
path: src/Bundle/Resources/config/Algorithms/signature_experimental.php
892887

893-
-
894-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:decode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
895-
count: 1
896-
path: src/Bundle/Serializer/JWEEncoder.php
897-
898-
-
899-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:encode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
900-
count: 1
901-
path: src/Bundle/Serializer/JWEEncoder.php
902-
903888
-
904889
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:getRecipientIndex\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
905890
count: 1
@@ -915,26 +900,6 @@ parameters:
915900
count: 1
916901
path: src/Bundle/Serializer/JWEEncoder.php
917902

918-
-
919-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
920-
count: 1
921-
path: src/Bundle/Serializer/JWESerializer.php
922-
923-
-
924-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
925-
count: 1
926-
path: src/Bundle/Serializer/JWESerializer.php
927-
928-
-
929-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSEncoder\\:\\:decode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
930-
count: 1
931-
path: src/Bundle/Serializer/JWSEncoder.php
932-
933-
-
934-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSEncoder\\:\\:encode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
935-
count: 1
936-
path: src/Bundle/Serializer/JWSEncoder.php
937-
938903
-
939904
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSEncoder\\:\\:getSignatureIndex\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
940905
count: 1
@@ -950,16 +915,6 @@ parameters:
950915
count: 1
951916
path: src/Bundle/Serializer/JWSEncoder.php
952917

953-
-
954-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
955-
count: 1
956-
path: src/Bundle/Serializer/JWSSerializer.php
957-
958-
-
959-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
960-
count: 1
961-
path: src/Bundle/Serializer/JWSSerializer.php
962-
963918
-
964919
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\ClaimCheckerManager\\:\\:check\\(\\) has parameter \\$claims with no value type specified in iterable type array\\.$#"
965920
count: 1
@@ -1840,11 +1795,6 @@ parameters:
18401795
count: 1
18411796
path: src/Library/KeyManagement/KeyConverter/ECKey.php
18421797

1843-
-
1844-
message: "#^Access to an undefined property Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:\\$requestFactory\\.$#"
1845-
count: 1
1846-
path: src/Library/KeyManagement/UrlKeySetFactory.php
1847-
18481798
-
18491799
message: "#^Call to an undefined method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:sendPsrRequest\\(\\)\\.$#"
18501800
count: 1
@@ -1855,26 +1805,16 @@ parameters:
18551805
count: 1
18561806
path: src/Library/KeyManagement/UrlKeySetFactory.php
18571807

1858-
-
1859-
message: "#^Class Psr\\\\Http\\\\Client\\\\ClientInterface not found\\.$#"
1860-
count: 3
1861-
path: src/Library/KeyManagement/UrlKeySetFactory.php
1862-
18631808
-
18641809
message: "#^Instanceof between Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface and Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface will always evaluate to true\\.$#"
1865-
count: 3
1810+
count: 2
18661811
path: src/Library/KeyManagement/UrlKeySetFactory.php
18671812

18681813
-
18691814
message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:getContent\\(\\) should return string but returns mixed\\.$#"
18701815
count: 1
18711816
path: src/Library/KeyManagement/UrlKeySetFactory.php
18721817

1873-
-
1874-
message: "#^Result of && is always false\\.$#"
1875-
count: 1
1876-
path: src/Library/KeyManagement/UrlKeySetFactory.php
1877-
18781818
-
18791819
message: "#^Parameter \\#2 \\$recipient of method Jose\\\\Component\\\\NestedToken\\\\NestedTokenLoader\\:\\:checkContentTypeHeader\\(\\) expects int, int\\|null given\\.$#"
18801820
count: 1

phpunit.xml.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@
3232
<directory suffix=".php">./src</directory>
3333
</include>
3434
</source>
35+
<extensions>
36+
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
37+
<parameter name="maximum-count" value="50"/>
38+
<parameter name="maximum-duration" value="100"/>
39+
</bootstrap>
40+
</extensions>
3541
</phpunit>

src/Bundle/DependencyInjection/JoseFrameworkExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public function getAlias(): string
2929
return $this->alias;
3030
}
3131

32-
/**
33-
* @param array<array> $configs
34-
*/
3532
#[Override]
3633
public function load(array $configs, ContainerBuilder $container): void
3734
{

src/Library/KeyManagement/UrlKeySetFactory.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,6 @@ abstract class UrlKeySetFactory
2323
public function __construct(
2424
private readonly HttpClientInterface $client,
2525
) {
26-
if ($this->client instanceof ClientInterface) {
27-
trigger_deprecation(
28-
'web-token/jwt-library',
29-
'3.3',
30-
'Using "%s" with an instance of "%s" is deprecated, use "%s" instead.',
31-
self::class,
32-
ClientInterface::class,
33-
HttpClientInterface::class
34-
);
35-
}
36-
if (! $this->client instanceof HttpClientInterface && $this->requestFactory === null) {
37-
throw new RuntimeException(sprintf(
38-
'The request factory must be provided when using an instance of "%s" as client.',
39-
ClientInterface::class
40-
));
41-
}
4226
$this->cacheItemPool = new NullAdapter();
4327
}
4428

tests/Component/Console/KeySetCreationCommandTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Jose\Tests\Component\Console;
66

7+
use Ergebnis\PHPUnit\SlowTestDetector\Attribute\MaximumDuration;
78
use InvalidArgumentException;
89
use Jose\Component\Console\EcKeysetGeneratorCommand;
910
use Jose\Component\Console\OctKeysetGeneratorCommand;
@@ -158,6 +159,7 @@ public function iCannotCreateAnRsaKeySetWithoutKeySetSize(): void
158159
}
159160

160161
#[Test]
162+
#[MaximumDuration(500)]
161163
public function iCanCreateAnRsaKeySet(): void
162164
{
163165
$input = new ArrayInput([

tests/Component/KeyManagement/JWKFactoryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Jose\Tests\Component\KeyManagement;
66

7+
use Ergebnis\PHPUnit\SlowTestDetector\Attribute\MaximumDuration;
78
use Jose\Component\Core\Util\Base64UrlSafe;
89
use Jose\Component\Core\Util\ECKey;
910
use Jose\Component\KeyManagement\JWKFactory;
@@ -231,6 +232,7 @@ public function createFromValues(): void
231232

232233
#[DataProvider('dataKeys')]
233234
#[Test]
235+
#[MaximumDuration(500)]
234236
public function loadKeyPEMEncoded(string $filename, array $expectedValues): void
235237
{
236238
$jwk = JWKFactory::createFromKeyFile($filename);

0 commit comments

Comments
 (0)