diff --git a/src/Psl/Encoding/Base64/decode.php b/src/Psl/Encoding/Base64/decode.php new file mode 100644 index 0000000..35d4c3e --- /dev/null +++ b/src/Psl/Encoding/Base64/decode.php @@ -0,0 +1,33 @@ +) $fun * * @psalm-return Iter\Iterator + * + * @internal */ function lazy_iterator(callable $fun): Iter\Iterator { diff --git a/src/Psl/Internal/validate_offset.php b/src/Psl/Internal/validate_offset.php index 7082c43..689167d 100644 --- a/src/Psl/Internal/validate_offset.php +++ b/src/Psl/Internal/validate_offset.php @@ -15,6 +15,8 @@ use Psl; * @codeCoverageIgnore * * @throws Psl\Exception\InvariantViolationException If the offset is out-of-bounds. + * + * @internal */ function validate_offset(int $offset, int $length): int { diff --git a/src/Psl/Internal/validate_offset_lower_bound.php b/src/Psl/Internal/validate_offset_lower_bound.php index 9c6adf4..75691f9 100644 --- a/src/Psl/Internal/validate_offset_lower_bound.php +++ b/src/Psl/Internal/validate_offset_lower_bound.php @@ -13,6 +13,8 @@ use Psl; * @psalm-pure * * @throws Psl\Exception\InvariantViolationException If $offset is out-of-bounds. + * + * @internal */ function validate_offset_lower_bound(int $offset, int $length): int { diff --git a/tests/Psl/Encoding/Base64Test.php b/tests/Psl/Encoding/Base64Test.php new file mode 100644 index 0000000..06c02d6 --- /dev/null +++ b/tests/Psl/Encoding/Base64Test.php @@ -0,0 +1,36 @@ +expectException(Exception\RangeException::class); + + Base64\decode('@~=='); + } + + public function provideRandomBytes(): iterable + { + for ($i = 1; $i < 128; ++$i) { + yield [SecureRandom\bytes($i)]; + } + } +} diff --git a/tests/Psl/Encoding/HexTest.php b/tests/Psl/Encoding/HexTest.php new file mode 100644 index 0000000..7f20012 --- /dev/null +++ b/tests/Psl/Encoding/HexTest.php @@ -0,0 +1,49 @@ +expectException(Exception\RangeException::class); + + Hex\decode('gf'); + } + + public function testDecodeThrowsForAnOddNumberOfCharacters(): void + { + $this->expectException(Exception\RangeException::class); + + Hex\decode('f'); + } + + public function provideRandomBytes(): iterable + { + for ($i = 1; $i < 128; ++$i) { + yield [SecureRandom\bytes($i)]; + } + } +}