Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ function uuidv4(): string
$bytes = random_bytes(16);
$hex = bin2hex($bytes);
$chunks = str_split($hex, 4);
$chunks[3][0] = '4';
$chunks[3] = '4' . substr($chunks[3], 1);
return sprintf('%s%s-%s-%s-%s-%s%s%s', ...$chunks);
}
34 changes: 8 additions & 26 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ parameters:
path: examples/readmeRegisterStep1.php

-
message: '#^Parameter \#1 \$bytes of static method Firehed\\WebAuthn\\BinaryString\:\:fromBytes\(\) expects array\<int\>, array\<mixed, mixed\> given\.$#'
message: '#^Parameter \#1 \$bytes of static method Firehed\\WebAuthn\\BinaryString\:\:fromBytes\(\) expects array\<int\<0, 255\>\>, array\<mixed, mixed\> given\.$#'
identifier: argument.type
count: 8
count: 7
path: src/ArrayBufferResponseParser.php

-
message: '#^Parameter \#1 \$bytes of static method Firehed\\WebAuthn\\BinaryString\:\:fromBytes\(\) expects array\<int\<0, 255\>\>, non\-empty\-array\<mixed, mixed\> given\.$#'
identifier: argument.type
count: 1
path: src/ArrayBufferResponseParser.php

-
Expand Down Expand Up @@ -204,24 +210,6 @@ parameters:
count: 1
path: src/ChallengeLoaderInterface.php

-
message: '#^Binary operation "\+" between \(array\|float\|int\) and GMP results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/PublicKey/EllipticCurve.php

-
message: '#^Binary operation "\+" between mixed and mixed results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/PublicKey/EllipticCurve.php

-
message: '#^Parameter \#1 \$num1 of function gmp_cmp expects GMP\|int\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/PublicKey/EllipticCurve.php

-
message: '#^Parameter \#1 \$string of function strlen expects string, mixed given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -252,12 +240,6 @@ parameters:
count: 2
path: src/PublicKey/EllipticCurve.php

-
message: '#^Parameter \#2 \$num2 of function gmp_cmp expects GMP\|int\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/PublicKey/EllipticCurve.php

-
message: '#^Parameter \#1 \$value of static method Firehed\\WebAuthn\\COSE\\Algorithm\:\:from\(\) expects int\|string, mixed given\.$#'
identifier: argument.type
Expand Down
4 changes: 2 additions & 2 deletions src/BinaryString.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public function toBase64Url(): string
/**
* Turns a list of 8-bit integers into a BinaryString
*
* @param int[] $bytes
* @param int<0, 255>[] $bytes
*/
public static function fromBytes(array $bytes): BinaryString
{
return new BinaryString(implode('', array_map('chr', $bytes)));
return new BinaryString(implode('', array_map(chr(...), $bytes)));
}

public static function fromHex(string $hex): BinaryString
Expand Down
11 changes: 6 additions & 5 deletions src/PublicKey/EllipticCurve.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ private function isOnCurve(): bool

// This is only tested with P256 (secp256r1) but SHOULD be the same for
// the other curves (none of which are supported yet)/
$x3 = $x ** 3; // @phpstan-ignore binaryOp.invalid (phpstan/phpstan#12123)
$ax = $a * $x; // @phpstan-ignore binaryOp.invalid
$rhs = ($x3 + $ax + $b) % $p; // @phpstan-ignore binaryOp.invalid
$x3 = $x ** 3; // @phpstan-ignore pow.leftNonNumeric, binaryOp.invalid (phpstan/phpstan#14288)
$ax = $a * $x; // @phpstan-ignore mul.leftNonNumeric, mul.rightNonNumeric (phpstan/phpstan#14288)
// @phpstan-ignore plus.rightNonNumeric, mod.rightNonNumeric, binaryOp.invalid (phpstan/phpstan#14288)
$rhs = ($x3 + $ax + $b) % $p;

$y2 = $y ** 2; // @phpstan-ignore binaryOp.invalid
$lhs = $y2 % $p; // @phpstan-ignore binaryOp.invalid
$y2 = $y ** 2; // @phpstan-ignore pow.leftNonNumeric, binaryOp.invalid (phpstan/phpstan#14288)
$lhs = $y2 % $p; // @phpstan-ignore mod.rightNonNumeric, binaryOp.invalid (phpstan/phpstan#14288)

// Functionaly, `$lhs === $rhs` but avoids reference equality issues
// w/out having to introduce loose comparision ($lhs == $rhs works)
Expand Down
Loading