Skip to content

Commit 2ce91be

Browse files
committed
Fix inconsistencies in last deprecation notices
1 parent 290507d commit 2ce91be

38 files changed

+175
-254
lines changed

performance/JWE/EncryptionBench.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ abstract class EncryptionBench
4848
{
4949
private AlgorithmManager $algorithmsManager;
5050

51-
private CompressionMethodManager $compressionMethodsManager;
52-
5351
private JWESerializerManager $serializerManager;
5452

5553
public function init(): void
@@ -96,7 +94,7 @@ public function init(): void
9694
*/
9795
public function encryption(array $params): void
9896
{
99-
$jweBuilder = new JWEBuilder($this->getAlgorithmsManager(), $this->getCompressionMethodsManager());
97+
$jweBuilder = new JWEBuilder($this->getAlgorithmsManager());
10098
$jweBuilder
10199
->withPayload($params['payload'])
102100
->withAAD($this->getAAD())
@@ -113,7 +111,7 @@ public function encryption(array $params): void
113111
*/
114112
public function decryption(array $params): void
115113
{
116-
$jweLoader = new JWEDecrypter($this->getAlgorithmsManager(), $this->getCompressionMethodsManager());
114+
$jweLoader = new JWEDecrypter($this->getAlgorithmsManager());
117115
$jwe = $this->serializerManager->unserialize($params['input']);
118116
$keyset = JWKSet::createFromKeyData($params['recipient_keys']);
119117
$jweLoader->decryptUsingKeySet($jwe, $keyset, 0);
@@ -138,9 +136,4 @@ private function getAlgorithmsManager(): AlgorithmManager
138136
{
139137
return $this->algorithmsManager;
140138
}
141-
142-
private function getCompressionMethodsManager(): CompressionMethodManager
143-
{
144-
return $this->compressionMethodsManager;
145-
}
146139
}

phpstan-baseline.neon

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,21 +1095,6 @@ parameters:
10951095
count: 1
10961096
path: src/Bundle/Services/JWEDecrypter.php
10971097

1098-
-
1099-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:create\\(\\) has parameter \\$compressionMethods with no value type specified in iterable type array\\.$#"
1100-
count: 1
1101-
path: src/Bundle/Services/JWEDecrypterFactory.php
1102-
1103-
-
1104-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:create\\(\\) has parameter \\$contentEncryptionAlgorithms with no value type specified in iterable type array\\.$#"
1105-
count: 1
1106-
path: src/Bundle/Services/JWEDecrypterFactory.php
1107-
1108-
-
1109-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#"
1110-
count: 1
1111-
path: src/Bundle/Services/JWEDecrypterFactory.php
1112-
11131098
-
11141099
message: """
11151100
#^Parameter \\$compressionMethodManagerFactory of method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWEDecrypterFactory\\:\\:__construct\\(\\) has typehint with deprecated class Jose\\\\Component\\\\Encryption\\\\Compression\\\\CompressionMethodManagerFactory\\:
@@ -1123,31 +1108,6 @@ parameters:
11231108
count: 1
11241109
path: src/Bundle/Services/JWELoader.php
11251110

1126-
-
1127-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$compressionMethods with no value type specified in iterable type array\\.$#"
1128-
count: 1
1129-
path: src/Bundle/Services/JWELoaderFactory.php
1130-
1131-
-
1132-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$contentEncryptionAlgorithms with no value type specified in iterable type array\\.$#"
1133-
count: 1
1134-
path: src/Bundle/Services/JWELoaderFactory.php
1135-
1136-
-
1137-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$headerCheckers with no value type specified in iterable type array\\.$#"
1138-
count: 1
1139-
path: src/Bundle/Services/JWELoaderFactory.php
1140-
1141-
-
1142-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#"
1143-
count: 1
1144-
path: src/Bundle/Services/JWELoaderFactory.php
1145-
1146-
-
1147-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$serializers with no value type specified in iterable type array\\.$#"
1148-
count: 1
1149-
path: src/Bundle/Services/JWELoaderFactory.php
1150-
11511111
-
11521112
message: "#^Parameter \\#4 \\$signature of class Jose\\\\Bundle\\\\JoseFramework\\\\Event\\\\JWSLoadingSuccessEvent constructor expects int, int\\|null given\\.$#"
11531113
count: 1
@@ -1779,12 +1739,12 @@ parameters:
17791739
path: src/Library/Encryption/JWELoaderFactory.php
17801740

17811741
-
1782-
message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$headerCheckers with no value type specified in iterable type array\\.$#"
1742+
message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$encryptionAlgorithms with no value type specified in iterable type array\\.$#"
17831743
count: 1
17841744
path: src/Library/Encryption/JWELoaderFactory.php
17851745

17861746
-
1787-
message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$keyEncryptionAlgorithms with no value type specified in iterable type array\\.$#"
1747+
message: "#^Method Jose\\\\Component\\\\Encryption\\\\JWELoaderFactory\\:\\:create\\(\\) has parameter \\$headerCheckers with no value type specified in iterable type array\\.$#"
17881748
count: 1
17891749
path: src/Library/Encryption/JWELoaderFactory.php
17901750

src/Bundle/Resources/config/compression_methods.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
$container->set(CompressionMethodManagerFactory::class)
1717
->deprecate(
1818
'web-token/jwt-bundle',
19-
'3.3.X',
19+
'3.3.0',
2020
'The "%service_id%" service is deprecated and will be removed in version 4.0. Compression is not recommended for the JWE.'
2121
)
2222
->public();
2323

2424
$container->set(Deflate::class)
2525
->deprecate(
2626
'web-token/jwt-bundle',
27-
'3.3.X',
27+
'3.3.0',
2828
'The "%service_id%" service is deprecated and will be removed in version 4.0. Compression is not recommended for the JWE.'
2929
)
3030
->tag('jose.compression_method', [

src/Bundle/Services/JWEDecrypter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
final class JWEDecrypter extends BaseJWEDecrypter
1818
{
1919
public function __construct(
20-
AlgorithmManager $keyEncryptionAlgorithmManager,
21-
AlgorithmManager $contentEncryptionAlgorithmManager,
20+
AlgorithmManager $algorithmManager,
21+
null|AlgorithmManager $contentEncryptionAlgorithmManager,
2222
null|CompressionMethodManager $compressionMethodManager,
2323
private readonly EventDispatcherInterface $eventDispatcher
2424
) {
25-
parent::__construct($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager);
25+
parent::__construct($algorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager);
2626
}
2727

2828
public function decryptUsingKeySet(

src/Bundle/Services/JWEDecrypterFactory.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,26 @@ public function __construct(
2424
}
2525
}
2626

27+
/**
28+
* @param array<string> $encryptionAlgorithms
29+
* @param null|array<string> $contentEncryptionAlgorithms
30+
* @param null|array<string> $compressionMethods
31+
*/
2732
public function create(
28-
array $keyEncryptionAlgorithms,
29-
array $contentEncryptionAlgorithms,
33+
array $encryptionAlgorithms,
34+
null|array $contentEncryptionAlgorithms = null,
3035
null|array $compressionMethods = null
3136
): JWEDecrypter {
32-
$keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
33-
$contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithms);
37+
if ($contentEncryptionAlgorithms !== null) {
38+
trigger_deprecation(
39+
'web-token/jwt-library',
40+
'3.3.0',
41+
'The parameter "$contentEncryptionAlgorithms" is deprecated and will be removed in 4.0.0. Please set all algorithms in the first argument and set "null" instead.'
42+
);
43+
$encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms);
44+
}
45+
46+
$encryptionAlgorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms);
3447
if ($compressionMethods !== null) {
3548
trigger_deprecation(
3649
'web-token/jwt-library',
@@ -43,8 +56,8 @@ public function create(
4356
);
4457

4558
return new JWEDecrypter(
46-
$keyEncryptionAlgorithmManager,
47-
$contentEncryptionAlgorithmManager,
59+
$encryptionAlgorithmManager,
60+
null,
4861
$compressionMethodManager,
4962
$this->eventDispatcher
5063
);

src/Bundle/Services/JWELoaderFactory.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ public function __construct(
1717
) {
1818
}
1919

20+
/**
21+
* @param array<string> $serializers
22+
* @param array<string> $encryptionAlgorithms
23+
* @param array<string>|null $contentEncryptionAlgorithms
24+
* @param array<string>|null $compressionMethods
25+
* @param array<string> $headerCheckers
26+
*/
2027
public function create(
2128
array $serializers,
22-
array $keyEncryptionAlgorithms,
23-
array $contentEncryptionAlgorithms,
24-
null|array $compressionMethods,
29+
array $encryptionAlgorithms,
30+
null|array $contentEncryptionAlgorithms = null,
31+
null|array $compressionMethods = null,
2532
array $headerCheckers = []
2633
): JWELoader {
2734
$serializerManager = $this->jweSerializerManagerFactory->create($serializers);
2835
$jweDecrypter = $this->jweDecrypterFactory->create(
29-
$keyEncryptionAlgorithms,
36+
$encryptionAlgorithms,
3037
$contentEncryptionAlgorithms,
3138
$compressionMethods
3239
);

src/Library/Encryption/JWEBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class JWEBuilder
5151

5252
public function __construct(
5353
AlgorithmManager $algorithmManager,
54-
null|AlgorithmManager $contentEncryptionAlgorithmManager,
54+
null|AlgorithmManager $contentEncryptionAlgorithmManager = null,
5555
private readonly null|CompressionMethodManager $compressionManager = null
5656
) {
5757
if ($compressionManager !== null) {

src/Library/Encryption/JWEBuilderFactory.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,28 @@ public function __construct(
2626
* Creates a JWE Builder object using the given key encryption algorithms, content encryption algorithms and
2727
* compression methods.
2828
*
29-
* @param string[] $keyEncryptionAlgorithms
30-
* @param string[] $contentEncryptionAlgorithm
29+
* @param array<string> $encryptionAlgorithms
30+
* @param null|array<string> $contentEncryptionAlgorithm
3131
* @param null|string[] $compressionMethods
3232
*/
3333
public function create(
34-
array $keyEncryptionAlgorithms,
35-
array $contentEncryptionAlgorithm,
36-
null|array $compressionMethods
34+
array $encryptionAlgorithms,
35+
null|array $contentEncryptionAlgorithm = null,
36+
null|array $compressionMethods = null
3737
): JWEBuilder {
38-
$keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms);
39-
$contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithm);
38+
if ($contentEncryptionAlgorithm !== null) {
39+
trigger_deprecation(
40+
'web-token/jwt-library',
41+
'3.3.0',
42+
'The parameter "$contentEncryptionAlgorithm" is deprecated and will be removed in 4.0.0. Please set "null" instead.'
43+
);
44+
$encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithm);
45+
}
46+
$encryptionAlgorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms);
4047
$compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create(
4148
$compressionMethods
4249
);
4350

44-
return new JWEBuilder(
45-
$keyEncryptionAlgorithmManager,
46-
$contentEncryptionAlgorithmManager,
47-
$compressionMethodManager
48-
);
51+
return new JWEBuilder($encryptionAlgorithmManager, null, $compressionMethodManager);
4952
}
5053
}

src/Library/Encryption/JWEDecrypterFactory.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@ public function __construct(
2626
* Creates a JWE Decrypter object using the given key encryption algorithms, content encryption algorithms and
2727
* compression methods.
2828
*
29-
* @param string[] $keyEncryptionAlgorithms
30-
* @param string[] $contentEncryptionAlgorithms
29+
* @param string[] $encryptionAlgorithms
30+
* @param null|string[] $contentEncryptionAlgorithms
3131
* @param null|string[] $compressionMethods
3232
*/
3333
public function create(
34-
array $keyEncryptionAlgorithms,
35-
array $contentEncryptionAlgorithms,
36-
null|array $compressionMethods
34+
array $encryptionAlgorithms,
35+
null|array $contentEncryptionAlgorithms = null,
36+
null|array $compressionMethods = null
3737
): JWEDecrypter {
38-
$algorithmManager = $this->algorithmManagerFactory->create(
39-
array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms)
40-
);
38+
if ($contentEncryptionAlgorithms !== null) {
39+
$encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms);
40+
}
41+
42+
$algorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms);
4143
$compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create(
4244
$compressionMethods
4345
);

src/Library/Encryption/JWELoaderFactory.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ public function __construct(
2222
*/
2323
public function create(
2424
array $serializers,
25-
array $keyEncryptionAlgorithms,
26-
array $contentEncryptionAlgorithms,
27-
null|array $compressionMethods,
25+
array $encryptionAlgorithms,
26+
null|array $contentEncryptionAlgorithms = null,
27+
null|array $compressionMethods = null,
2828
array $headerCheckers = []
2929
): JWELoader {
30+
if ($contentEncryptionAlgorithms !== null) {
31+
$encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms);
32+
}
3033
$serializerManager = $this->jweSerializerManagerFactory->create($serializers);
31-
$jweDecrypter = $this->jweDecrypterFactory->create(
32-
$keyEncryptionAlgorithms,
33-
$contentEncryptionAlgorithms,
34-
$compressionMethods
35-
);
34+
$jweDecrypter = $this->jweDecrypterFactory->create($encryptionAlgorithms, null, $compressionMethods);
3635
if ($this->headerCheckerManagerFactory !== null) {
3736
$headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers);
3837
} else {

src/Library/NestedToken/NestedTokenBuilderFactory.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,24 @@ public function __construct(
2424
* compression methods.
2525
*
2626
* @param array<string> $jwe_serializers
27-
* @param array<string> $keyEncryptionAlgorithms
28-
* @param array<string> $contentEncryptionAlgorithms
27+
* @param array<string> $encryptionAlgorithms
28+
* @param null|array<string> $contentEncryptionAlgorithms
2929
* @param null|array<string> $compressionMethods
3030
* @param array<string> $jws_serializers
3131
* @param array<string> $signatureAlgorithms
3232
*/
3333
public function create(
3434
array $jwe_serializers,
35-
array $keyEncryptionAlgorithms,
36-
array $contentEncryptionAlgorithms,
35+
array $encryptionAlgorithms,
36+
null|array $contentEncryptionAlgorithms,
3737
null|array $compressionMethods,
3838
array $jws_serializers,
3939
array $signatureAlgorithms
4040
): NestedTokenBuilder {
41-
$jweBuilder = $this->jweBuilderFactory->create(
42-
$keyEncryptionAlgorithms,
43-
$contentEncryptionAlgorithms,
44-
$compressionMethods
45-
);
41+
if ($contentEncryptionAlgorithms !== null) {
42+
$encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms);
43+
}
44+
$jweBuilder = $this->jweBuilderFactory->create($encryptionAlgorithms, null, $compressionMethods);
4645
$jweSerializerManager = $this->jweSerializerManagerFactory->create($jwe_serializers);
4746
$jwsBuilder = $this->jwsBuilderFactory->create($signatureAlgorithms);
4847
$jwsSerializerManager = $this->jwsSerializerManagerFactory->create($jws_serializers);

tests/Bundle/JoseFramework/Functional/Encryption/JWEBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function theJWEBuilderFactoryCanCreateAJWEBuilder(): void
4444
$jweFactory = $container->get(JWEBuilderFactoryService::class);
4545
static::assertInstanceOf(JWEBuilderFactoryService::class, $jweFactory);
4646

47-
$jweFactory->create(['RSA1_5'], ['A256GCM'], ['DEF']);
47+
$jweFactory->create(['RSA1_5'], ['A256GCM']);
4848
}
4949

5050
#[Test]

tests/Bundle/JoseFramework/Functional/Encryption/JWEDecrypterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function theJWEDecrypterFactoryIsAvailable(): void
3434
}
3535

3636
#[Test]
37-
public static function theWEDecrypterFactoryCanCreateAJWEDecrypter(): void
37+
public static function theJWEDecrypterFactoryCanCreateAJWEDecrypter(): void
3838
{
3939
static::ensureKernelShutdown();
4040
$client = static::createClient();
@@ -44,7 +44,7 @@ public static function theWEDecrypterFactoryCanCreateAJWEDecrypter(): void
4444
$jweFactory = $container->get(JWEDecrypterFactoryService::class);
4545
static::assertInstanceOf(JWEDecrypterFactoryService::class, $jweFactory);
4646

47-
$jweFactory->create(['RSA1_5'], ['A256GCM'], ['DEF']);
47+
$jweFactory->create(['RSA1_5', 'A256GCM']);
4848
}
4949

5050
#[Test]

tests/Bundle/JoseFramework/Functional/Encryption/JWELoaderTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ public static function theWELoaderFactoryCanCreateAJWELoader(): void
4444
$jweLoaderFactory = $container->get(JWELoaderFactoryAlias::class);
4545
static::assertInstanceOf(JWELoaderFactoryAlias::class, $jweLoaderFactory);
4646

47-
$jwe = $jweLoaderFactory->create(['jwe_compact'], ['RSA1_5'], ['A256GCM'], ['DEF']);
47+
$jwe = $jweLoaderFactory->create(['jwe_compact'], ['RSA1_5'], ['A256GCM']);
4848

4949
static::assertSame(['jwe_compact'], $jwe->getSerializerManager()->names());
5050
static::assertSame(['RSA1_5'], $jwe->getJweDecrypter()->getKeyEncryptionAlgorithmManager()->list());
5151
static::assertSame(['A256GCM'], $jwe->getJweDecrypter()->getContentEncryptionAlgorithmManager()->list());
52-
static::assertSame(['DEF'], $jwe->getJweDecrypter()->getCompressionMethodManager()->list());
5352
}
5453

5554
#[Test]

tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public function prepend(ContainerBuilder $container): void
4444
true
4545
);
4646
ConfigurationHelper::addJWSLoader($container, 'jws_loader2', ['jws_compact'], ['HS512'], [], true);
47-
ConfigurationHelper::addJWEBuilder($container, 'builder2', ['RSA-OAEP-256'], ['A128GCM'], ['DEF'], true);
48-
ConfigurationHelper::addJWEDecrypter($container, 'loader2', ['RSA-OAEP-256'], ['A128GCM'], ['DEF'], true);
47+
ConfigurationHelper::addJWEBuilder($container, 'builder2', ['RSA-OAEP-256'], ['A128GCM'], true);
48+
ConfigurationHelper::addJWEDecrypter($container, 'loader2', ['RSA-OAEP-256'], ['A128GCM'], true);
4949
ConfigurationHelper::addJWESerializer(
5050
$container,
5151
'jwe_serializer2',

0 commit comments

Comments
 (0)