Skip to content

Commit 52da412

Browse files
authored
CI/CD fixed (#425)
* Tweet Action version * Minor modifications * Rector/ECS fixed
1 parent f59e6d5 commit 52da412

File tree

20 files changed

+80
-90
lines changed

20 files changed

+80
-90
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mu: vendor ## Mutation tests
2-
vendor/bin/infection -s --threads=$(nproc) --min-msi=40 --min-covered-msi=40
2+
vendor/bin/infection -s --threads=$$(nproc) --min-msi=40 --min-covered-msi=40
33

44
tests: vendor ## Run all tests
55
vendor/bin/phpunit --color
@@ -8,7 +8,7 @@ cc: vendor ## Show test coverage rates (HTML)
88
vendor/bin/phpunit --coverage-html ./build
99

1010
cs: vendor ## Fix all files using defined ECS rules
11-
vendor/bin/ecs check --fix
11+
XDEBUG_MODE=off vendor/bin/ecs check --fix
1212

1313
tu: vendor ## Run only unit tests
1414
vendor/bin/phpunit --color --group Unit
@@ -20,19 +20,19 @@ tf: vendor ## Run only functional tests
2020
vendor/bin/phpunit --color --group Functional
2121

2222
st: vendor ## Run static analyse
23-
vendor/bin/phpstan analyse
23+
XDEBUG_MODE=off vendor/bin/phpstan analyse
2424

2525

2626
################################################
2727

2828
ci-mu: vendor ## Mutation tests (for Github only)
29-
vendor/bin/infection --logger-github -s --threads=$(nproc) --min-msi=40 --min-covered-msi=40
29+
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=40 --min-covered-msi=40
3030

3131
ci-cc: vendor ## Show test coverage rates (console)
3232
vendor/bin/phpunit --coverage-text
3333

3434
ci-cs: vendor ## Check all files using defined ECS rules
35-
vendor/bin/ecs check
35+
XDEBUG_MODE=off vendor/bin/ecs check
3636

3737
################################################
3838

@@ -42,7 +42,7 @@ vendor: composer.json composer.lock
4242
composer install
4343

4444
rector: vendor ## Check all files using Rector
45-
vendor/bin/rector process --ansi --dry-run --xdebug
45+
XDEBUG_MODE=off vendor/bin/rector process --ansi --dry-run --xdebug
4646

4747
.DEFAULT_GOAL := help
4848
help:

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,13 @@
8383
"php-http/mock-client": "^1.5",
8484
"php-parallel-lint/php-parallel-lint": "^1.3",
8585
"phpbench/phpbench": "^1.2",
86-
"phpstan/extension-installer": "^1.1",
8786
"phpstan/phpstan": "^1.8",
8887
"phpstan/phpstan-deprecation-rules": "^1.0",
8988
"phpstan/phpstan-phpunit": "^1.1",
9089
"phpstan/phpstan-strict-rules": "^1.4",
9190
"phpunit/phpunit": "^9.5.23",
9291
"qossmic/deptrac-shim": "^1.0",
93-
"rector/rector": "^0.14",
92+
"rector/rector": "^0.15",
9493
"roave/security-advisories": "dev-latest",
9594
"symfony/browser-kit": "^6.1.3",
9695
"symfony/finder": "^5.4|^6.0",
@@ -145,7 +144,6 @@
145144
"config": {
146145
"sort-packages": true,
147146
"allow-plugins": {
148-
"phpstan/extension-installer": true,
149147
"infection/extension-installer": true,
150148
"composer/package-versions-deprecated": true
151149
}

rector.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Rector\Config\RectorConfig;
66
use Rector\Core\ValueObject\PhpVersion;
77
use Rector\Doctrine\Set\DoctrineSetList;
8-
use Rector\Php74\Rector\Property\TypedPropertyRector;
98
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
109
use Rector\PHPUnit\Set\PHPUnitSetList;
1110
use Rector\Set\ValueObject\LevelSetList;
@@ -20,7 +19,6 @@
2019
SymfonyLevelSetList::UP_TO_SYMFONY_54,
2120
SymfonySetList::SYMFONY_CODE_QUALITY,
2221
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
23-
SymfonySetList::SYMFONY_STRICT,
2422
DoctrineSetList::DOCTRINE_CODE_QUALITY,
2523
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
2624
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
@@ -33,14 +31,13 @@
3331
$config->parallel();
3432
$config->paths([__DIR__ . '/src', __DIR__ . '/performance', __DIR__ . '/tests']);
3533
$config->skip([
34+
\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class => __DIR__ . '/tests',
35+
\Rector\PHPUnit\Rector\Class_\AnnotationWithValueToAttributeRector::class => __DIR__ . '/tests',
3636
__DIR__ . '/src/Component/Core/JWKSet.php',
3737
__DIR__ . '/src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSource.php',
3838
__DIR__ . '/src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSetSource.php',
3939
]);
4040
$config->phpVersion(PhpVersion::PHP_81);
4141
$config->importNames();
4242
$config->importShortClasses();
43-
44-
$services = $config->services();
45-
$services->set(TypedPropertyRector::class);
4643
};

src/Component/Core/Util/RSAKey.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44

55
namespace Jose\Component\Core\Util;
66

7-
use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence;
8-
use SpomkyLabs\Pki\ASN1\Type\Primitive\BitString;
9-
use SpomkyLabs\Pki\ASN1\Type\Primitive\Integer;
10-
use SpomkyLabs\Pki\ASN1\Type\Primitive\NullType;
11-
use SpomkyLabs\Pki\ASN1\Type\Primitive\ObjectIdentifier;
12-
use SpomkyLabs\Pki\ASN1\Type\Primitive\OctetString;
13-
use SpomkyLabs\Pki\CryptoEncoding\PEM;
14-
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Asymmetric\RSAEncryptionAlgorithmIdentifier;
157
use function array_key_exists;
168
use function count;
179
use InvalidArgumentException;
1810
use function is_array;
1911
use Jose\Component\Core\JWK;
2012
use ParagonIE\ConstantTime\Base64UrlSafe;
2113
use RuntimeException;
14+
use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence;
15+
use SpomkyLabs\Pki\ASN1\Type\Primitive\BitString;
16+
use SpomkyLabs\Pki\ASN1\Type\Primitive\Integer;
17+
use SpomkyLabs\Pki\ASN1\Type\Primitive\OctetString;
18+
use SpomkyLabs\Pki\CryptoEncoding\PEM;
19+
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Asymmetric\RSAEncryptionAlgorithmIdentifier;
2220
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RSA\RSAPrivateKey;
2321
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RSA\RSAPublicKey;
2422

@@ -182,8 +180,8 @@ public static function exponentiate(self $key, BigInteger $c): BigInteger
182180
throw new RuntimeException();
183181
}
184182
if ($key->isPublic() || $key->getCoefficient() === null || count($key->getPrimes()) === 0 || count(
185-
$key->getExponents()
186-
) === 0) {
183+
$key->getExponents()
184+
) === 0) {
187185
return $c->modPow($key->getExponent(), $key->getModulus());
188186
}
189187

@@ -216,9 +214,9 @@ private function populateBigIntegers(): void
216214
$this->convertBase64StringToBigInteger($this->values['q']),
217215
];
218216
if (array_key_exists('dp', $this->values) && array_key_exists('dq', $this->values) && array_key_exists(
219-
'qi',
220-
$this->values
221-
)) {
217+
'qi',
218+
$this->values
219+
)) {
222220
$this->exponents = [
223221
$this->convertBase64StringToBigInteger($this->values['dp']),
224222
$this->convertBase64StringToBigInteger($this->values['dq']),

src/Component/KeyManagement/KeyConverter/KeyConverter.php

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

55
namespace Jose\Component\KeyManagement\KeyConverter;
66

7-
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\EC\ECPublicKey;
87
use function array_key_exists;
98
use function count;
109
use function extension_loaded;
@@ -134,10 +133,10 @@ public static function loadFromX5C(array $x5c): array
134133
}
135134
foreach ($x5c as $id => $cert) {
136135
$x5c[$id] = '-----BEGIN CERTIFICATE-----' . PHP_EOL . chunk_split(
137-
(string) $cert,
138-
64,
139-
PHP_EOL
140-
) . '-----END CERTIFICATE-----';
136+
(string) $cert,
137+
64,
138+
PHP_EOL
139+
) . '-----END CERTIFICATE-----';
141140
$x509 = openssl_x509_read($x5c[$id]);
142141
if ($x509 === false) {
143142
throw new InvalidArgumentException('Unable to load the certificate chain');

src/EncryptionAlgorithm/Experimental/KeyEncryption/AESCTR.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function encryptKey(JWK $key, string $cek, array $completeHeader, array &
4545
public function decryptKey(JWK $key, string $encrypted_cek, array $header): string
4646
{
4747
$k = $this->getKey($key);
48-
isset($header['iv']) ||throw new InvalidArgumentException('The header parameter "iv" is missing.');
49-
is_string($header['iv']) ||throw new InvalidArgumentException('The header parameter "iv" is not valid.');
48+
isset($header['iv']) || throw new InvalidArgumentException('The header parameter "iv" is missing.');
49+
is_string($header['iv']) || throw new InvalidArgumentException('The header parameter "iv" is not valid.');
5050
$iv = Base64UrlSafe::decode($header['iv']);
5151

5252
$result = openssl_decrypt($encrypted_cek, $this->getMode(), $k, OPENSSL_RAW_DATA, $iv);

src/EncryptionAlgorithm/Experimental/KeyEncryption/Chacha20Poly1305.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function encryptKey(JWK $key, string $cek, array $completeHeader, array &
5959
public function decryptKey(JWK $key, string $encrypted_cek, array $header): string
6060
{
6161
$k = $this->getKey($key);
62-
isset($header['nonce']) ||throw new InvalidArgumentException('The header parameter "nonce" is missing.');
63-
is_string($header['nonce']) ||throw new InvalidArgumentException('The header parameter "nonce" is not valid.');
62+
isset($header['nonce']) || throw new InvalidArgumentException('The header parameter "nonce" is missing.');
63+
is_string($header['nonce']) || throw new InvalidArgumentException('The header parameter "nonce" is not valid.');
6464
$nonce = Base64UrlSafe::decode($header['nonce']);
6565
if (mb_strlen($nonce, '8bit') !== 12) {
6666
throw new InvalidArgumentException('The header parameter "nonce" is not valid.');

src/EncryptionAlgorithm/KeyEncryption/AESGCMKW/AESGCMKW.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$ad
4646
public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader): string
4747
{
4848
$kek = $this->getKey($key);
49-
(isset($completeHeader['iv']) && is_string($completeHeader['iv'])) || throw new InvalidArgumentException('Parameter "iv" is missing.');
50-
(isset($completeHeader['tag']) && is_string($completeHeader['tag'])) || throw new InvalidArgumentException('Parameter "tag" is missing.');
49+
(isset($completeHeader['iv']) && is_string($completeHeader['iv'])) || throw new InvalidArgumentException(
50+
'Parameter "iv" is missing.'
51+
);
52+
(isset($completeHeader['tag']) && is_string($completeHeader['tag'])) || throw new InvalidArgumentException(
53+
'Parameter "tag" is missing.'
54+
);
5155

5256
$tag = Base64UrlSafe::decode($completeHeader['tag']);
5357
$iv = Base64UrlSafe::decode($completeHeader['iv']);

src/EncryptionAlgorithm/KeyEncryption/ECDHES/AbstractECDH.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str
140140
}
141141

142142
/**
143-
* @return JWK[]
144143
* @param array<string, mixed> $additional_header_values
144+
* @return JWK[]
145145
*/
146146
protected function getKeysFromPublicKey(
147147
JWK $recipient_key,

tests/Bundle/JoseFramework/Functional/Serializer/JWEEncoderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ public function theJWEEncoderShouldThrowOnUnsupportedFormatWhenDecoding(): void
188188
$serializer->decode($jweString, 'jwe_json_flattened');
189189
}
190190

191-
public function encoderServiceDataProvider(): array
191+
public static function encoderServiceDataProvider(): array
192192
{
193193
return [
194194
'indirect serializer' => ['serializer'],
195195
'direct serializer' => [JWEEncoder::class],
196196
];
197197
}
198198

199-
public function jweFormatDataProvider(): array
199+
public static function jweFormatDataProvider(): array
200200
{
201201
return [
202202
'jwe_compact with indirect serializer' => ['jwe_compact', 'serializer'],

tests/Bundle/JoseFramework/Functional/Serializer/JWESerializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function serializerServiceDataProvider(): array
8181
];
8282
}
8383

84-
public function jweFormatDataProvider(): array
84+
public static function jweFormatDataProvider(): array
8585
{
8686
return [
8787
'jwe_compact with indirect serializer' => ['jwe_compact', 'serializer'],

tests/Bundle/JoseFramework/Functional/Serializer/JWSEncoderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function serializerServiceDataProvider(): array
190190
];
191191
}
192192

193-
public function jwsFormatDataProvider(): array
193+
public static function jwsFormatDataProvider(): array
194194
{
195195
return [
196196
'jws_compact with indirect serializer' => ['jws_compact', 'serializer'],

tests/Bundle/JoseFramework/Functional/Serializer/JWSSerializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function serializerServiceDataProvider(): array
8181
];
8282
}
8383

84-
public function jwsFormatDataProvider(): array
84+
public static function jwsFormatDataProvider(): array
8585
{
8686
return [
8787
'jws_compact with indirect serializer' => ['jws_compact', 'serializer'],

tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function encryptionAlgorithmsWithMinimalRsaKey(string $encryption_algorit
8686
static::assertTrue($jweDecrypter->decryptUsingKey($loaded, $key, 0));
8787
}
8888

89-
public function dataEncryptionAlgorithms(): array
89+
public static function dataEncryptionAlgorithms(): array
9090
{
9191
return [['RSA1_5'], ['RSA-OAEP'], ['RSA-OAEP-256']];
9292
}

tests/Component/KeyManagement/CertificateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function loadCertificate(string $file, array $expected_values): void
113113
static::assertEqualsCanonicalizing($expected_values, $result);
114114
}
115115

116-
public function dataLoadCertificate(): array
116+
public static function dataLoadCertificate(): array
117117
{
118118
return [
119119
[

tests/Component/KeyManagement/JWKFactoryTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,11 @@ public function createFromPublicEC512KeyFile(string $filename, string $expectedJ
232232
$jwk = JWKFactory::createFromKeyFile($filename);
233233

234234
// Then
235-
static::assertSame(
236-
$expectedJWK,
237-
json_encode($jwk, JSON_THROW_ON_ERROR)
238-
);
235+
static::assertSame($expectedJWK, json_encode($jwk, JSON_THROW_ON_ERROR));
239236
static::assertSame($content, ECKey::convertPublicKeyToPEM($jwk));
240237
}
241238

242-
public function publicKeysAndPem(): iterable
239+
public static function publicKeysAndPem(): iterable
243240
{
244241
yield [
245242
__DIR__ . '/Keys/EC/public.es256.key',
@@ -288,7 +285,7 @@ public function loadKeyPEMEncoded(string $filename, array $expectedValues): void
288285
/**
289286
* @return array<int, array<string, mixed>>
290287
*/
291-
public function dataKeys(): array
288+
public static function dataKeys(): array
292289
{
293290
return [
294291
[

tests/Component/KeyManagement/Keys/ECKeysTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Jose\Tests\Component\KeyManagement\Keys;
66

7-
use Jose\Component\Core\Util\ECKey;
87
use const DIRECTORY_SEPARATOR;
98
use InvalidArgumentException;
109
use Jose\Component\Core\JWK;
10+
use Jose\Component\Core\Util\ECKey;
1111
use Jose\Component\KeyManagement\JWKFactory;
1212
use Jose\Component\KeyManagement\KeyConverter\KeyConverter;
1313
use PHPUnit\Framework\TestCase;

tests/Component/KeyManagement/Keys/RSAKeysTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace Jose\Tests\Component\KeyManagement\Keys;
66

7-
use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence;
8-
use SpomkyLabs\Pki\ASN1\Type\Primitive\RelativeOID;
9-
use SpomkyLabs\Pki\CryptoEncoding\PEM;
107
use const DIRECTORY_SEPARATOR;
118
use InvalidArgumentException;
129
use Jose\Component\Core\JWK;
@@ -142,7 +139,7 @@ public function loadPrivateRSAKey(): void
142139
$content = trim(file_get_contents($file));
143140

144141
// When
145-
$rsaKey = RSAKey::createFromPEM('file://'.$file);
142+
$rsaKey = RSAKey::createFromPEM('file://' . $file);
146143

147144
// Then
148145
static::assertEqualsCanonicalizing([

0 commit comments

Comments
 (0)