Skip to content

Commit 7697d6c

Browse files
committed
Add type to class constants
1 parent 49d4ddb commit 7697d6c

11 files changed

Lines changed: 35 additions & 35 deletions

src/Signer/Blake2b.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
final readonly class Blake2b implements Signer
1313
{
14-
private const MINIMUM_KEY_LENGTH_IN_BITS = 256;
14+
private const int MINIMUM_KEY_LENGTH_IN_BITS = 256;
1515

1616
public function algorithmId(): string
1717
{

src/Signer/Ecdsa/MultibyteStringConverter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
*/
3434
final readonly class MultibyteStringConverter implements SignatureConverter
3535
{
36-
private const ASN1_SEQUENCE = '30';
37-
private const ASN1_INTEGER = '02';
38-
private const ASN1_MAX_SINGLE_BYTE = 128;
39-
private const ASN1_LENGTH_2BYTES = '81';
40-
private const ASN1_BIG_INTEGER_LIMIT = '7f';
41-
private const ASN1_NEGATIVE_INTEGER = '00';
42-
private const BYTE_SIZE = 2;
36+
private const string ASN1_SEQUENCE = '30';
37+
private const string ASN1_INTEGER = '02';
38+
private const int ASN1_MAX_SINGLE_BYTE = 128;
39+
private const string ASN1_LENGTH_2BYTES = '81';
40+
private const string ASN1_BIG_INTEGER_LIMIT = '7f';
41+
private const string ASN1_NEGATIVE_INTEGER = '00';
42+
private const int BYTE_SIZE = 2;
4343

4444
public function toAsn1(string $points, int $length): string
4545
{

src/Signer/OpenSSL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
abstract readonly class OpenSSL implements Signer
2828
{
29-
protected const KEY_TYPE_MAP = [
29+
protected const array KEY_TYPE_MAP = [
3030
OPENSSL_KEYTYPE_RSA => 'RSA',
3131
OPENSSL_KEYTYPE_DSA => 'DSA',
3232
OPENSSL_KEYTYPE_DH => 'DH',

src/Signer/Rsa.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
abstract readonly class Rsa extends OpenSSL
99
{
10-
private const MINIMUM_KEY_LENGTH = 2048;
10+
private const int MINIMUM_KEY_LENGTH = 2048;
1111

1212
final public function sign(string $payload, Key $key): string
1313
{

src/SodiumBase64Polyfill.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
/** @internal */
1919
final readonly class SodiumBase64Polyfill
2020
{
21-
public const SODIUM_BASE64_VARIANT_ORIGINAL = 1;
22-
public const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
23-
public const SODIUM_BASE64_VARIANT_URLSAFE = 5;
24-
public const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7;
21+
public const int SODIUM_BASE64_VARIANT_ORIGINAL = 1;
22+
public const int SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
23+
public const int SODIUM_BASE64_VARIANT_URLSAFE = 5;
24+
public const int SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7;
2525

2626
/** @return ($decoded is non-empty-string ? non-empty-string : string) */
2727
public static function bin2base64(string $decoded, int $variant): string

src/Token/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
final readonly class Parser implements ParserInterface
1919
{
20-
private const MICROSECOND_PRECISION = 6;
20+
private const int MICROSECOND_PRECISION = 6;
2121

2222
public function __construct(private Decoder $decoder)
2323
{

src/Token/RegisteredClaims.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
interface RegisteredClaims
1212
{
13-
public const ALL = [
13+
public const array ALL = [
1414
self::AUDIENCE,
1515
self::EXPIRATION_TIME,
1616
self::ID,
@@ -20,7 +20,7 @@ interface RegisteredClaims
2020
self::SUBJECT,
2121
];
2222

23-
public const DATE_CLAIMS = [
23+
public const array DATE_CLAIMS = [
2424
self::ISSUED_AT,
2525
self::NOT_BEFORE,
2626
self::EXPIRATION_TIME,
@@ -31,47 +31,47 @@ interface RegisteredClaims
3131
*
3232
* @see https://tools.ietf.org/html/rfc7519#section-4.1.3
3333
*/
34-
public const AUDIENCE = 'aud';
34+
public const string AUDIENCE = 'aud';
3535

3636
/**
3737
* Identifies the expiration time on or after which the JWT MUST NOT be accepted for processing
3838
*
3939
* @see https://tools.ietf.org/html/rfc7519#section-4.1.4
4040
*/
41-
public const EXPIRATION_TIME = 'exp';
41+
public const string EXPIRATION_TIME = 'exp';
4242

4343
/**
4444
* Provides a unique identifier for the JWT
4545
*
4646
* @see https://tools.ietf.org/html/rfc7519#section-4.1.7
4747
*/
48-
public const ID = 'jti';
48+
public const string ID = 'jti';
4949

5050
/**
5151
* Identifies the time at which the JWT was issued
5252
*
5353
* @see https://tools.ietf.org/html/rfc7519#section-4.1.6
5454
*/
55-
public const ISSUED_AT = 'iat';
55+
public const string ISSUED_AT = 'iat';
5656

5757
/**
5858
* Identifies the principal that issued the JWT
5959
*
6060
* @see https://tools.ietf.org/html/rfc7519#section-4.1.1
6161
*/
62-
public const ISSUER = 'iss';
62+
public const string ISSUER = 'iss';
6363

6464
/**
6565
* Identifies the time before which the JWT MUST NOT be accepted for processing
6666
*
6767
* https://tools.ietf.org/html/rfc7519#section-4.1.5
6868
*/
69-
public const NOT_BEFORE = 'nbf';
69+
public const string NOT_BEFORE = 'nbf';
7070

7171
/**
7272
* Identifies the principal that is the subject of the JWT.
7373
*
7474
* https://tools.ietf.org/html/rfc7519#section-4.1.2
7575
*/
76-
public const SUBJECT = 'sub';
76+
public const string SUBJECT = 'sub';
7777
}

tests/Benchmark/AlgorithmsBench.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
#[Bench\Warmup(3)]
1515
abstract class AlgorithmsBench
1616
{
17-
private const SUPPORTED_ALGORITHMS = [
17+
private const array SUPPORTED_ALGORITHMS = [
1818
'hmac' => ['HS256', 'HS384', 'HS512'],
1919
'rsa' => ['RS256', 'RS384', 'RS512'],
2020
'ecdsa' => ['ES256', 'ES384', 'ES512'],
2121
'eddsa' => ['EdDSA'],
2222
'blake2b' => ['BLAKE2B'],
2323
];
2424

25-
protected const PAYLOAD = "It\xe2\x80\x99s a dangerous business, Frodo, going out your door. You step onto the road"
26-
. ", and if you don't keep your feet, there\xe2\x80\x99s no knowing where you might be swept"
25+
protected const string PAYLOAD = "It\xe2\x80\x99s a dangerous business, Frodo, going out your door. You step "
26+
. " onto the road, and if you don't keep your feet, there\xe2\x80\x99s no knowing where you might be swept"
2727
. ' off to.';
2828

2929
#[Bench\Subject]

tests/Signer/Blake2bTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
#[PHPUnit\UsesClass(SodiumBase64Polyfill::class)]
1919
final class Blake2bTest extends TestCase
2020
{
21-
private const KEY_ONE = 'GOu4rLyVCBxmxP+sbniU68ojAja5PkRdvv7vNvBCqDQ=';
22-
private const KEY_TWO = 'Pu7gywseH+R5HLIWnMll4rEg1ltjUPq/P9WwEzAsAb8=';
23-
private const CONTENTS = 'test';
24-
private const EXPECTED_HASH_WITH_KEY_ONE = '/TG5kmkav/YGl3I9uQiv4cm1VN6Q0zPCom4G7+p74JU=';
21+
private const string KEY_ONE = 'GOu4rLyVCBxmxP+sbniU68ojAja5PkRdvv7vNvBCqDQ=';
22+
private const string KEY_TWO = 'Pu7gywseH+R5HLIWnMll4rEg1ltjUPq/P9WwEzAsAb8=';
23+
private const string CONTENTS = 'test';
24+
private const string EXPECTED_HASH_WITH_KEY_ONE = '/TG5kmkav/YGl3I9uQiv4cm1VN6Q0zPCom4G7+p74JU=';
2525

26-
private const SHORT_KEY = 'PIBQuM5PopdMxtmTWmyvNA==';
26+
private const string SHORT_KEY = 'PIBQuM5PopdMxtmTWmyvNA==';
2727

2828
private InMemory $keyOne;
2929
private InMemory $keyTwo;

tests/SodiumBase64PolyfillTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#[PHPUnit\UsesClass(CannotDecodeContent::class)]
2121
final class SodiumBase64PolyfillTest extends TestCase
2222
{
23-
private const B64 = 'I+o2tVq8ynY=';
24-
private const B64URL = 'lZ-2HIl9dTz_Oy0nAb-2gvKdG0jhHJ36XB2rWAKj8Uo=';
23+
private const string B64 = 'I+o2tVq8ynY=';
24+
private const string B64URL = 'lZ-2HIl9dTz_Oy0nAb-2gvKdG0jhHJ36XB2rWAKj8Uo=';
2525

2626
#[PHPUnit\Test]
2727
public function constantsMatchExtensionOnes(): void

0 commit comments

Comments
 (0)