Skip to content

Commit

Permalink
deps: allow brick/math 0.12
Browse files Browse the repository at this point in the history
deps: other dev deps update
  • Loading branch information
Spomky committed Jan 29, 2024
1 parent 4921258 commit 95fbab9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"require": {
"php": ">=8.0",
"ext-mbstring": "*",
"brick/math": "^0.9|^0.10|^0.11|^0.12"
"brick/math": "^0.9|^0.10|^0.11|^0.12",
"symfony/polyfill-mbstring": "^1.28"
},
"require-dev": {
"ext-json": "*",
Expand Down
2 changes: 2 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ClassNotation\ProtectedToPrivateFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
Expand Down Expand Up @@ -52,6 +53,7 @@
$config->rule(ProtectedToPrivateFixer::class);
$config->rule(DeclareStrictTypesFixer::class);
$config->rule(NativeConstantInvocationFixer::class);
$config->rule(MbStrFunctionsFixer::class);
$config->rule(LinebreakAfterOpeningTagFixer::class);
$config->rule(CombineConsecutiveIssetsFixer::class);
$config->rule(CombineConsecutiveUnsetsFixer::class);
Expand Down
6 changes: 3 additions & 3 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function process(Stream $stream, bool $breakable): CBORObject
case CBORObject::FUTURE_USE_3: //30
throw new InvalidArgumentException(sprintf(
'Cannot parse the data. Found invalid Additional Information "%s" (%d).',
str_pad(decbin($ai), 8, '0', STR_PAD_LEFT),
mb_str_pad(decbin($ai), 8, '0', STR_PAD_LEFT, '8bit'),
$ai
));
case CBORObject::LENGTH_INDEFINITE: //31
Expand Down Expand Up @@ -129,7 +129,7 @@ private function processFinite(Stream $stream, int $mt, int $ai, ?string $val):
default:
throw new RuntimeException(sprintf(
'Unsupported major type "%s" (%d).',
str_pad(decbin($mt), 5, '0', STR_PAD_LEFT),
mb_str_pad(decbin($mt), 5, '0', STR_PAD_LEFT, '8bit'),
$mt
)); // Should never append
}
Expand Down Expand Up @@ -190,7 +190,7 @@ private function processInfinite(Stream $stream, int $mt, bool $breakable): CBOR
default :
throw new InvalidArgumentException(sprintf(
'Cannot parse the data. Found infinite length for Major Type "%s" (%d).',
str_pad(decbin($mt), 5, '0', STR_PAD_LEFT),
mb_str_pad(decbin($mt), 5, '0', STR_PAD_LEFT, '8bit'),
$mt
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/LengthCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static function computeLength(int $length): array

private static function hex2bin(string $data): string
{
$data = str_pad($data, (int) (2 ** ceil(log(mb_strlen($data, '8bit'), 2))), '0', STR_PAD_LEFT);
$data = mb_str_pad($data, (int) (2 ** ceil(log(mb_strlen($data, '8bit'), 2))), '0', STR_PAD_LEFT, '8bit');
$result = hex2bin($data);
if ($result === false) {
throw new InvalidArgumentException('Unable to convert the data');
Expand Down
6 changes: 3 additions & 3 deletions src/NegativeIntegerObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ private static function createBigInteger(BigInteger $integer): self
break;
case $computed_value->isLessThan(BigInteger::fromBase('FF', 16)):
$ai = 24;
$data = self::hex2bin(str_pad($computed_value->toBase(16), 2, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($computed_value->toBase(16), 2, '0', STR_PAD_LEFT, '8bit'));
break;
case $computed_value->isLessThan(BigInteger::fromBase('FFFF', 16)):
$ai = 25;
$data = self::hex2bin(str_pad($computed_value->toBase(16), 4, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($computed_value->toBase(16), 4, '0', STR_PAD_LEFT, '8bit'));
break;
case $computed_value->isLessThan(BigInteger::fromBase('FFFFFFFF', 16)):
$ai = 26;
$data = self::hex2bin(str_pad($computed_value->toBase(16), 8, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($computed_value->toBase(16), 8, '0', STR_PAD_LEFT, '8bit'));
break;
default:
throw new InvalidArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/TimestampTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function normalize(): DateTimeInterface
if (mb_strlen($parts[1], '8bit') > 6) {
$parts[1] = mb_substr($parts[1], 0, 6, '8bit');
} else {
$parts[1] = str_pad($parts[1], 6, '0', STR_PAD_RIGHT);
$parts[1] = mb_str_pad($parts[1], 6, '0', STR_PAD_RIGHT);
}
}
$formatted = DateTimeImmutable::createFromFormat('U.u', implode('.', $parts));
Expand Down
6 changes: 3 additions & 3 deletions src/UnsignedIntegerObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ private static function createBigInteger(BigInteger $integer): self
break;
case $integer->isLessThan(BigInteger::fromBase('FF', 16)):
$ai = 24;
$data = self::hex2bin(str_pad($integer->toBase(16), 2, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($integer->toBase(16), 2, '0', STR_PAD_LEFT, '8bit'));
break;
case $integer->isLessThan(BigInteger::fromBase('FFFF', 16)):
$ai = 25;
$data = self::hex2bin(str_pad($integer->toBase(16), 4, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($integer->toBase(16), 4, '0', STR_PAD_LEFT, '8bit'));
break;
case $integer->isLessThan(BigInteger::fromBase('FFFFFFFF', 16)):
$ai = 26;
$data = self::hex2bin(str_pad($integer->toBase(16), 8, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($integer->toBase(16), 8, '0', STR_PAD_LEFT, '8bit'));
break;
default:
throw new InvalidArgumentException(
Expand Down

0 comments on commit 95fbab9

Please sign in to comment.