From 904222030389f294b1dbe42d81468491e6fabcb1 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 26 Apr 2025 08:14:35 +0200 Subject: [PATCH 1/4] Refactor constructors and update dependencies. Simplified constructors by removing unnecessary line breaks. Updated `composer.json` dependencies to newer versions, ensuring compatibility and alignment with modern standards. Adjusted test data to a cleaner format, improving readability and maintainability. --- composer.json | 8 ++--- src/Library/Encryption/JWEBuilder.php | 5 ++- src/Library/Encryption/JWEDecrypter.php | 5 ++- .../KeyManagement/JWKFactoryTest.php | 36 +++++++++---------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/composer.json b/composer.json index 341e4c71..ba255ceb 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,7 @@ "ekino/phpstan-banned-code": "^2.0|^3.0", "ergebnis/phpunit-slow-test-detector": "^2.14", "infection/infection": "^0.29", - "matthiasnoback/symfony-config-test": "5.1.x-dev", + "matthiasnoback/symfony-config-test": "^6.0", "paragonie/sodium_compat": "^1.20|^2.0", "php-parallel-lint/php-parallel-lint": "^1.3", "phpbench/phpbench": "^1.2", @@ -78,14 +78,14 @@ "phpstan/phpstan-phpunit": "^1.1|^2.0", "phpstan/phpstan-strict-rules": "^1.4|^2.0", "phpstan/phpstan-symfony": "^1.3|^2.0", - "phpunit/phpunit": "^10.5.10|^11.0", - "qossmic/deptrac": "^2.0", + "phpunit/phpunit": "^10.5.10|^11.0|^12.0", + "deptrac/deptrac": "^2.0", "rector/rector": "^1.0|^2.0", "roave/security-advisories": "dev-latest", "spomky-labs/aes-key-wrap": "^7.0", "staabm/phpstan-dba": "^0.2.79|^0.3", "staabm/phpstan-todo-by": "^0.1.25|^0.2", - "struggle-for-php/sfp-phpstan-psr-log": "^0.20|^0.21|^0.22|^0.23", + "struggle-for-php/sfp-phpstan-psr-log": "^0.20|^0.21|^0.22|^0.23|^0.24", "symfony/browser-kit": "^7.0", "symfony/http-client": "^7.0", "symfony/clock": "^7.0", diff --git a/src/Library/Encryption/JWEBuilder.php b/src/Library/Encryption/JWEBuilder.php index bc5b1ca9..7c5ac213 100644 --- a/src/Library/Encryption/JWEBuilder.php +++ b/src/Library/Encryption/JWEBuilder.php @@ -46,9 +46,8 @@ class JWEBuilder private readonly AlgorithmManager $contentEncryptionAlgorithmManager; - public function __construct( - AlgorithmManager $algorithmManager, - ) { + public function __construct(AlgorithmManager $algorithmManager) + { $keyEncryptionAlgorithms = []; $contentEncryptionAlgorithms = []; foreach ($algorithmManager->all() as $algorithm) { diff --git a/src/Library/Encryption/JWEDecrypter.php b/src/Library/Encryption/JWEDecrypter.php index ef67e044..b70b3296 100644 --- a/src/Library/Encryption/JWEDecrypter.php +++ b/src/Library/Encryption/JWEDecrypter.php @@ -28,9 +28,8 @@ class JWEDecrypter private readonly AlgorithmManager $contentEncryptionAlgorithmManager; - public function __construct( - AlgorithmManager $algorithmManager - ) { + public function __construct(AlgorithmManager $algorithmManager) + { $keyEncryptionAlgorithms = []; $contentEncryptionAlgorithms = []; foreach ($algorithmManager->all() as $key => $algorithm) { diff --git a/tests/Component/KeyManagement/JWKFactoryTest.php b/tests/Component/KeyManagement/JWKFactoryTest.php index 26b9b512..d511d393 100644 --- a/tests/Component/KeyManagement/JWKFactoryTest.php +++ b/tests/Component/KeyManagement/JWKFactoryTest.php @@ -246,40 +246,40 @@ public function loadKeyPEMEncoded(string $filename, array $expectedValues): void public static function dataKeys(): iterable { yield [ - 'filename' => __DIR__ . '/Keys/ED/public-ed448.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/public-ed448.pem', + [ 'kty' => 'OKP', 'crv' => 'Ed448', 'x' => 'wwHKDV7s4fBhmFSTzYorlaToGXNcsa7SakZdekT_sexD5ENj5lWP6_KX9_u--w_QSm80rNOodj0A', ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/public-ed25519.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/public-ed25519.pem', + [ 'kty' => 'OKP', 'crv' => 'Ed25519', 'x' => 'wrI33AEj15KHHYplueUE5cnJKtbM8oVHFf6wGnw2oOE', ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/public-X448.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/public-X448.pem', + [ 'kty' => 'OKP', 'crv' => 'X448', 'x' => 'UoPD73NQACC8A-otDUVun4IrMsk775ShMRf4ThDrq4xY2eAI-pOIVujrvBXXd9g8gUNwBT0fmnc', ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/public-X25519.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/public-X25519.pem', + [ 'kty' => 'OKP', 'crv' => 'X25519', 'x' => '3OJLiffmOCQGtil23QGyn0nk9EBKoZx6P-6o-EnsBB4', ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/private-ed448.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/private-ed448.pem', + [ 'kty' => 'OKP', 'crv' => 'Ed448', 'x' => 'wwHKDV7s4fBhmFSTzYorlaToGXNcsa7SakZdekT_sexD5ENj5lWP6_KX9_u--w_QSm80rNOodj0A', @@ -287,8 +287,8 @@ public static function dataKeys(): iterable ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/private-X448.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/private-X448.pem', + [ 'kty' => 'OKP', 'crv' => 'X448', 'x' => 'UoPD73NQACC8A-otDUVun4IrMsk775ShMRf4ThDrq4xY2eAI-pOIVujrvBXXd9g8gUNwBT0fmnc', @@ -296,8 +296,8 @@ public static function dataKeys(): iterable ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/private-ed25519.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/private-ed25519.pem', + [ 'kty' => 'OKP', 'crv' => 'Ed25519', 'x' => 'wrI33AEj15KHHYplueUE5cnJKtbM8oVHFf6wGnw2oOE', @@ -305,8 +305,8 @@ public static function dataKeys(): iterable ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/private-secp384r1-with-public.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/private-secp384r1-with-public.pem', + [ 'kty' => 'EC', 'crv' => 'P-384', 'd' => '31taDOPQnlNl2aBC_EaGTqVGjGN_qg6iuLwP6cVTmhKMQ5PTL67wS6mmyKi8GdVP', @@ -315,8 +315,8 @@ public static function dataKeys(): iterable ], ]; yield [ - 'filename' => __DIR__ . '/Keys/ED/private-X25519.pem', - 'expectedValues' => [ + __DIR__ . '/Keys/ED/private-X25519.pem', + [ 'kty' => 'OKP', 'crv' => 'X25519', 'x' => '3OJLiffmOCQGtil23QGyn0nk9EBKoZx6P-6o-EnsBB4', From 3e38e099dbbcf79210888fbb6f44830bb9b82131 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 26 Apr 2025 08:20:23 +0200 Subject: [PATCH 2/4] Update composer dependencies and simplify version constraints Removed the unnecessary "ext-json" dependency in both files. Simplified the "brick/math" version constraint for clarity and consistency. No functional changes introduced. --- composer.json | 3 +-- src/Library/composer.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ba255ceb..35e81eda 100644 --- a/composer.json +++ b/composer.json @@ -47,9 +47,8 @@ }, "require": { "php": ">=8.2", - "ext-json": "*", "ext-openssl": "*", - "brick/math": "^0.12 || ^0.13", + "brick/math": "^0.12|^0.13", "psr/clock": "^1.0", "psr/event-dispatcher": "^1.0", "spomky-labs/pki-framework": "^1.2.1", diff --git a/src/Library/composer.json b/src/Library/composer.json index 39ea8638..9f984d33 100644 --- a/src/Library/composer.json +++ b/src/Library/composer.json @@ -39,8 +39,7 @@ }, "require": { "php": ">=8.2", - "ext-json": "*", - "brick/math": "^0.12 || ^0.13", + "brick/math": "^0.12|^0.13", "psr/clock": "^1.0", "spomky-labs/pki-framework": "^1.2.1" }, From fc05f4acb28ef499d893109fd3a45289c865b468 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 26 Apr 2025 08:20:29 +0200 Subject: [PATCH 3/4] Update workflow to use 'ubuntu-latest' for integration jobs Switched from 'ubuntu-20.04' to 'ubuntu-latest' in the GitHub Actions workflow. This ensures the use of the most up-to-date environment for integration testing, reducing potential compatibility issues. --- .github/workflows/integrate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index f3343958..0487ce5c 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -209,7 +209,7 @@ jobs: needs: - "byte_level" - "syntax_errors" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-latest" steps: - name: "Checkout code" uses: "actions/checkout@v4" From 7fd68ecd713ac70d16ea1c350c2a18f48d41d149 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 26 Apr 2025 08:21:15 +0200 Subject: [PATCH 4/4] Update phpstan-baseline.neon to reflect updated method signatures Adjusted error baseline messages to correspond with the renamed classes and methods in the dependency injection sources. This ensures the baseline reflects the current code structure and resolves outdated references. --- phpstan-baseline.neon | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4c9388cb..b77dc759 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -223,13 +223,13 @@ parameters: path: src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php - - message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:load\(\) expects array, mixed given\.$#' + message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Checker\\ClaimChecker\:\:load\(\) expects array, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php - - message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' + message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Checker\\ClaimChecker\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php @@ -757,13 +757,13 @@ parameters: path: src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php - - message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:load\(\) expects array, mixed given\.$#' + message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Encryption\\JWEBuilder\:\:load\(\) expects array, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php - - message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' + message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Encryption\\AbstractEncryptionSource\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php @@ -2365,13 +2365,13 @@ parameters: path: src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php - - message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:load\(\) expects array, mixed given\.$#' + message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\NestedToken\\NestedTokenBuilder\:\:load\(\) expects array, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php - - message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' + message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\NestedToken\\NestedTokenBuilder\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php @@ -3367,13 +3367,13 @@ parameters: path: src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php - - message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:load\(\) expects array, mixed given\.$#' + message: '#^Parameter \#1 \$configs of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Signature\\JWSBuilder\:\:load\(\) expects array, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php - - message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Source\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' + message: '#^Parameter \#1 \$node of method Jose\\Bundle\\JoseFramework\\DependencyInjection\\Source\\Signature\\AbstractSignatureSource\:\:getNodeDefinition\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition, mixed given\.$#' identifier: argument.type count: 1 path: src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php