diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml new file mode 100644 index 00000000..dd8e196c --- /dev/null +++ b/.github/workflows/infection.yml @@ -0,0 +1,37 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow + +name: "Integrate" + +on: + push: + branches: + - "*.x" + +jobs: + mutation_testing: + name: "5️⃣ Mutation Testing" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-latest" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.1" + extensions: "json, mbstring, openssl, sqlite3, curl, uuid" + + - name: "Checkout code" + uses: "actions/checkout@v4" + + - name: "Fetch Git base reference" + run: "git fetch --depth=1 origin ${GITHUB_BASE_REF}" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + composer-options: "--optimize-autoloader" + + - name: "Execute Infection" + run: "make ci-mu" diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index f67607a4..00d39dce 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -145,34 +145,6 @@ jobs: - name: "Check coding style" run: "make ci-cs" - mutation_testing: - name: "5️⃣ Mutation Testing" - needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-latest" - steps: - - name: "Set up PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.1" - extensions: "json, mbstring, openssl, sqlite3, curl, uuid" - - - name: "Checkout code" - uses: "actions/checkout@v4" - - - name: "Fetch Git base reference" - run: "git fetch --depth=1 origin ${GITHUB_BASE_REF}" - - - name: "Install dependencies" - uses: "ramsey/composer-install@v2" - with: - dependency-versions: "highest" - composer-options: "--optimize-autoloader" - - - name: "Execute Infection" - run: "make ci-mu" - rector_checkstyle: name: "6️⃣ Rector Checkstyle" needs: diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e088029c..d81f9184 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1870,11 +1870,6 @@ parameters: count: 1 path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|null given\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php b/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php index 308e4e62..9027a8e7 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php @@ -74,9 +74,9 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str throw new InvalidArgumentException('Invalid key parameter "crv"'); } switch ($crv) { - case 'P-256' : - case 'P-384' : - case 'P-521' : + case 'P-256': + case 'P-384': + case 'P-521': $curve = $this->getCurve($crv); if (function_exists('openssl_pkey_derive')) { try { @@ -115,7 +115,7 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str return $this->convertDecToBin(EcDH::computeSharedKey($curve, $pub_key, $priv_key)); - case 'X25519' : + case 'X25519': $this->checkSodiumExtensionIsAvailable(); $x = $public_key->get('x'); if (! is_string($x)) { @@ -130,7 +130,7 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str return sodium_crypto_scalarmult($sKey, $recipientPublickey); - default : + default: throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv)); } } @@ -212,19 +212,19 @@ private function checkKey(JWK $key, bool $is_private): void throw new InvalidArgumentException('Invalid key parameter "crv"'); } switch ($crv) { - case 'P-256' : - case 'P-384' : - case 'P-521' : + case 'P-256': + case 'P-384': + case 'P-521': if (! $key->has('y')) { throw new InvalidArgumentException('The key parameter "y" is missing.'); } break; - case 'X25519' : + case 'X25519': break; - default : + default: throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv)); } if ($is_private === true && ! $key->has('d')) { @@ -279,14 +279,14 @@ private function createOKPKey(string $curve): JWK $this->checkSodiumExtensionIsAvailable(); switch ($curve) { - case 'X25519' : + case 'X25519': $keyPair = sodium_crypto_box_keypair(); $d = sodium_crypto_box_secretkey($keyPair); $x = sodium_crypto_box_publickey($keyPair); break; - case 'Ed25519' : + case 'Ed25519': $keyPair = sodium_crypto_sign_keypair(); $secret = sodium_crypto_sign_secretkey($keyPair); $secretLength = mb_strlen($secret, '8bit'); @@ -295,7 +295,7 @@ private function createOKPKey(string $curve): JWK break; - default : + default: throw new InvalidArgumentException(sprintf('Unsupported "%s" curve', $curve)); } diff --git a/src/Library/Encryption/JWEBuilder.php b/src/Library/Encryption/JWEBuilder.php index 2e3e675c..0baafb96 100644 --- a/src/Library/Encryption/JWEBuilder.php +++ b/src/Library/Encryption/JWEBuilder.php @@ -434,11 +434,11 @@ private function determineCEK(array &$additionalHeader): string } switch ($this->keyManagementMode) { - case KeyEncryption::MODE_ENCRYPT : - case KeyEncryption::MODE_WRAP : + case KeyEncryption::MODE_ENCRYPT: + case KeyEncryption::MODE_WRAP: return $this->createCEK($this->contentEncryptionAlgorithm->getCEKSize()); - case KeyEncryption::MODE_AGREEMENT : + case KeyEncryption::MODE_AGREEMENT: if (count($this->recipients) !== 1) { throw new LogicException( 'Unable to encrypt for multiple recipients using key agreement algorithms.' @@ -465,7 +465,7 @@ private function determineCEK(array &$additionalHeader): string $additionalHeader ); - case KeyEncryption::MODE_DIRECT : + case KeyEncryption::MODE_DIRECT: if (count($this->recipients) !== 1) { throw new LogicException( 'Unable to encrypt for multiple recipients using key agreement algorithms.' @@ -483,7 +483,7 @@ private function determineCEK(array &$additionalHeader): string return Base64UrlSafe::decodeNoPadding($k); - default : + default: throw new InvalidArgumentException(sprintf( 'Unsupported key management mode "%s".', $this->keyManagementMode diff --git a/tests/Component/Signature/RFC7520/NestingTest.php b/tests/Component/Signature/RFC7520/NestingTest.php index 2152c5ce..40ddb17e 100644 --- a/tests/Component/Signature/RFC7520/NestingTest.php +++ b/tests/Component/Signature/RFC7520/NestingTest.php @@ -53,6 +53,9 @@ public function signatureVerification(): void static::assertTrue($jwsVerifier->verifyWithKey($loaded_compact_json, $signature_key, 0)); static::assertSame($signature_header, $loaded_compact_json->getSignature(0)->getProtectedHeader()); - static::assertSame($payload, json_decode((string) $loaded_compact_json->getPayload(), true, 512, JSON_THROW_ON_ERROR)); + static::assertSame( + $payload, + json_decode((string) $loaded_compact_json->getPayload(), true, 512, JSON_THROW_ON_ERROR) + ); } }