Skip to content

Commit 00d4cef

Browse files
authored
EC2Key and OkpKey class now supports curves as strings (#56)
EC2Key and OkpKey class now supports curves as strings
1 parent 9e0cc49 commit 00d4cef

File tree

21 files changed

+229
-69
lines changed

21 files changed

+229
-69
lines changed

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@
2929
}
3030
},
3131
"require-dev": {
32-
"infection/infection": "^0.26.12",
32+
"infection/infection": "^0.27",
3333
"phpstan/phpstan": "^1.7",
3434
"phpstan/phpstan-deprecation-rules": "^1.0",
3535
"phpstan/phpstan-phpunit": "^1.1",
3636
"phpstan/phpstan-strict-rules": "^1.2",
37-
"phpunit/phpunit": "^10.0",
38-
"rector/rector": "^0.15",
39-
"symplify/easy-coding-standard": "^11.0",
37+
"phpunit/phpunit": "^10.1",
38+
"rector/rector": "^0.17",
39+
"symplify/easy-coding-standard": "^12.0",
4040
"symfony/phpunit-bridge": "^6.1",
4141
"ekino/phpstan-banned-code": "^1.0",
4242
"php-parallel-lint/php-parallel-lint": "^1.3",
43-
"qossmic/deptrac-shim": "^1.0"
43+
"qossmic/deptrac-shim": "^1.0",
44+
"phpstan/extension-installer": "^1.3"
4445
},
4546
"autoload-dev": {
4647
"psr-4": {
@@ -49,7 +50,8 @@
4950
},
5051
"config": {
5152
"allow-plugins": {
52-
"infection/extension-installer": false
53+
"infection/extension-installer": true,
54+
"phpstan/extension-installer": true
5355
}
5456
},
5557
"suggest": {

ecs.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@
2020
use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer;
2121
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
2222
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
23-
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestClassRequiresCoversFixer;
2423
use PhpCsFixer\Fixer\ReturnNotation\SimplifiedNullReturnFixer;
2524
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
2625
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
2726
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
2827
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
2928
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypehintFixer;
29+
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
3030
use Symplify\EasyCodingStandard\Config\ECSConfig;
3131
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
3232

33-
$header = '';
34-
35-
return static function (ECSConfig $config) use ($header): void {
33+
return static function (ECSConfig $config): void {
34+
$header = '';
3635
$config->import(SetList::PSR_12);
3736
$config->import(SetList::CLEAN_CODE);
3837
$config->import(SetList::DOCTRINE_ANNOTATIONS);
@@ -87,9 +86,11 @@
8786
'import_constants' => true,
8887
'import_functions' => true,
8988
]);
90-
91-
$config->services()
92-
->remove(PhpUnitTestClassRequiresCoversFixer::class);
89+
$config->skip([
90+
MethodChainingIndentationFixer::class => [
91+
__DIR__ . '*/DependencyInjection/Configuration.php',
92+
],
93+
]);
9394

9495
$config->parallel();
9596
$config->paths([

phpstan-baseline.neon

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,60 @@ parameters:
55
count: 1
66
path: src/Algorithm/Mac/Hmac.php
77

8+
-
9+
message: "#^Method Cose\\\\Algorithm\\\\Signature\\\\ECDSA\\\\ECSignature\\:\\:fromAsn1\\(\\) should return string but returns string\\|false\\.$#"
10+
count: 1
11+
path: src/Algorithm/Signature/ECDSA/ECSignature.php
12+
13+
-
14+
message: "#^Method Cose\\\\Algorithm\\\\Signature\\\\ECDSA\\\\ECSignature\\:\\:toAsn1\\(\\) should return string but returns string\\|false\\.$#"
15+
count: 1
16+
path: src/Algorithm/Signature/ECDSA/ECSignature.php
17+
18+
-
19+
message: "#^Parameter \\#1 \\$signature of function sodium_crypto_sign_verify_detached expects non\\-empty\\-string, string given\\.$#"
20+
count: 1
21+
path: src/Algorithm/Signature/EdDSA/EdDSA.php
22+
23+
-
24+
message: "#^Parameter \\#2 \\$secret_key of function sodium_crypto_sign_detached expects non\\-empty\\-string, string given\\.$#"
25+
count: 1
26+
path: src/Algorithm/Signature/EdDSA/EdDSA.php
27+
28+
-
29+
message: "#^Parameter \\#3 \\$public_key of function sodium_crypto_sign_verify_detached expects non\\-empty\\-string, string given\\.$#"
30+
count: 1
31+
path: src/Algorithm/Signature/EdDSA/EdDSA.php
32+
833
-
934
message: "#^Parameter \\#1 \\$length of function random_bytes expects int\\<1, max\\>, int given\\.$#"
1035
count: 1
1136
path: src/Algorithm/Signature/RSA/PSSRSA.php
1237

1338
-
14-
message: "#^Cannot cast mixed to (string|int)\\.$#"
15-
count: 7
16-
path: src/Key/Ec2Key.php
39+
message: "#^Parameter \\#1 \\$array of function current expects array\\|object, array\\|false given\\.$#"
40+
count: 1
41+
path: src/BigInteger.php
1742

1843
-
19-
message: "#^Cannot cast mixed to int\\.$#"
44+
message: "#^Parameter \\#1 \\$string of function ltrim expects string, string\\|false given\\.$#"
2045
count: 1
21-
path: src/Key/RsaKey.php
46+
path: src/BigInteger.php
2247

2348
-
2449
message: "#^Cannot cast mixed to int\\.$#"
2550
count: 1
26-
path: src/Key/SymmetricKey.php
51+
path: src/Key/Ec2Key.php
52+
53+
-
54+
message: "#^Cannot cast mixed to string\\.$#"
55+
count: 2
56+
path: src/Key/Ec2Key.php
57+
58+
-
59+
message: "#^Method Cose\\\\Key\\\\Ec2Key\\:\\:curve\\(\\) should return int\\|string but returns mixed\\.$#"
60+
count: 1
61+
path: src/Key/Ec2Key.php
2762

2863
-
2964
message: "#^Method Cose\\\\Key\\\\Ec2Key\\:\\:d\\(\\) should return string but returns mixed\\.$#"
@@ -52,7 +87,12 @@ parameters:
5287

5388
-
5489
message: "#^Cannot cast mixed to int\\.$#"
55-
count: 3
90+
count: 1
91+
path: src/Key/OkpKey.php
92+
93+
-
94+
message: "#^Method Cose\\\\Key\\\\OkpKey\\:\\:curve\\(\\) should return int\\|string but returns mixed\\.$#"
95+
count: 1
5696
path: src/Key/OkpKey.php
5797

5898
-
@@ -65,6 +105,11 @@ parameters:
65105
count: 1
66106
path: src/Key/OkpKey.php
67107

108+
-
109+
message: "#^Cannot cast mixed to int\\.$#"
110+
count: 1
111+
path: src/Key/RsaKey.php
112+
68113
-
69114
message: "#^Method Cose\\\\Key\\\\RsaKey\\:\\:QInv\\(\\) should return string but returns mixed\\.$#"
70115
count: 1
@@ -126,9 +171,16 @@ parameters:
126171
path: src/Key/RsaKey.php
127172

128173
-
129-
message: "#^Method Cose\\\\Key\\\\SymmetricKey\\:\\:k\\(\\) should return string but returns mixed\\.$#"
174+
message: "#^Parameter \\#1 \\$array of function current expects array\\|object, array\\|false given\\.$#"
175+
count: 1
176+
path: src/Key/RsaKey.php
177+
178+
-
179+
message: "#^Cannot cast mixed to int\\.$#"
130180
count: 1
131181
path: src/Key/SymmetricKey.php
132182

133-
- '#Parameter \#\d+ \$.* of .* expects .*, .* given\.#'
134-
- '#Method .* should return string but returns string\|false\.#'
183+
-
184+
message: "#^Method Cose\\\\Key\\\\SymmetricKey\\:\\:k\\(\\) should return string but returns mixed\\.$#"
185+
count: 1
186+
path: src/Key/SymmetricKey.php

phpstan.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@ parameters:
55

66
includes:
77
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
8-
- vendor/phpstan/phpstan-strict-rules/rules.neon
9-
- vendor/phpstan/phpstan-phpunit/extension.neon
10-
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
11-
- vendor/phpstan/phpstan-phpunit/rules.neon
12-
- vendor/ekino/phpstan-banned-code/extension.neon
138
- phpstan-baseline.neon

phpunit.xml.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
55
colors="true"
6-
cacheDirectory=".phpunit.cache"
76
>
8-
<coverage>
9-
<include>
10-
<directory suffix=".php">src</directory>
11-
</include>
12-
</coverage>
7+
<coverage/>
138
<testsuites>
149
<testsuite name="all">
1510
<directory>tests/</directory>
@@ -23,4 +18,9 @@
2318
<server name="SHELL_VERBOSITY" value="-1"/>
2419
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
2520
</php>
21+
<source>
22+
<include>
23+
<directory>src</directory>
24+
</include>
25+
</source>
2626
</phpunit>

rector.php

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

55
use Rector\Config\RectorConfig;
66
use Rector\Core\ValueObject\PhpVersion;
7+
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector;
8+
use Rector\Doctrine\Set\DoctrineSetList;
9+
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
10+
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
11+
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
712
use Rector\PHPUnit\Set\PHPUnitSetList;
813
use Rector\Set\ValueObject\LevelSetList;
914
use Rector\Set\ValueObject\SetList;
@@ -13,19 +18,21 @@
1318
return static function (RectorConfig $config): void {
1419
$config->import(SetList::DEAD_CODE);
1520
$config->import(LevelSetList::UP_TO_PHP_81);
16-
$config->import(SymfonyLevelSetList::UP_TO_SYMFONY_62);
17-
$config->import(SymfonySetList::SYMFONY_CODE_QUALITY);
21+
$config->import(SymfonyLevelSetList::UP_TO_SYMFONY_60);
22+
$config->import(SymfonySetList::SYMFONY_50_TYPES);
1823
$config->import(SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES);
24+
$config->import(SymfonySetList::SYMFONY_CODE_QUALITY);
1925
$config->import(SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION);
2026
$config->import(SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES);
21-
$config->import(PHPUnitSetList::PHPUNIT_EXCEPTION);
22-
$config->import(PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD);
23-
$config->import(PHPUnitSetList::PHPUNIT_100);
24-
$config->import(PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER);
27+
$config->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);
28+
$config->import(DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES);
29+
$config->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
30+
$config->import(PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES);
31+
$config->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_100);
2532
$config->paths([__DIR__ . '/src', __DIR__ . '/tests']);
33+
$config->services()->remove(PreferPHPUnitThisCallRector::class);
2634
$config->phpVersion(PhpVersion::PHP_81);
2735
$config->parallel();
2836
$config->importNames();
29-
$config->importNames();
3037
$config->importShortClasses();
3138
};

src/Algorithm/Mac/Hmac.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Cose\Key\SymmetricKey;
99
use InvalidArgumentException;
1010

11+
/**
12+
* @see \Cose\Tests\Algorithm\Mac\HmacTest
13+
*/
1114
abstract class Hmac implements Mac
1215
{
1316
public function hash(string $data, Key $key): string

src/Algorithm/Manager.php

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

55
namespace Cose\Algorithm;
66

7-
use function array_key_exists;
87
use InvalidArgumentException;
8+
use function array_key_exists;
99

1010
final class Manager
1111
{

src/Algorithm/ManagerFactory.php

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

55
namespace Cose\Algorithm;
66

7-
use function array_key_exists;
87
use InvalidArgumentException;
8+
use function array_key_exists;
99

1010
final class ManagerFactory
1111
{

src/Algorithm/Signature/ECDSA/ECDSA.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use function openssl_sign;
1212
use function openssl_verify;
1313

14+
/**
15+
* @see \Cose\Tests\Algorithm\Signature\ECDSA\ECDSATest
16+
*/
1417
abstract class ECDSA implements Signature
1518
{
1619
public function sign(string $data, Key $key): string

0 commit comments

Comments
 (0)