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 81d5dff commit 5bd70aa
Show file tree
Hide file tree
Showing 32 changed files with 603 additions and 539 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
},
"require": {
"php": ">=8.0",
"brick/math": "^0.9|^0.10|^0.11",
"brick/math": "^0.9|^0.10|^0.11|^0.12",
"ext-mbstring": "*"
},
"require-dev": {
"ext-json": "*",
"ekino/phpstan-banned-code": "^1.0",
"infection/infection": "^0.26",
"infection/infection": "^0.27",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-beberlei-assert": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^10.0",
"rector/rector": "^0.15",
"rector/rector": "^0.19",
"roave/security-advisories": "dev-latest",
"symfony/var-dumper": "^6.0",
"symplify/easy-coding-standard": "^11.1",
"symfony/var-dumper": "^6.0|^7.0",
"symplify/easy-coding-standard": "^12.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"qossmic/deptrac-shim": "^1.0"
},
Expand Down
7 changes: 3 additions & 4 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
$config->import(SetList::NAMESPACES);
$config->import(SetList::STRICT);

$services = $config->services();
$config->rule(StrictParamFixer::class);
$config->rule(StrictComparisonFixer::class);
$config->rule(ArrayIndentationFixer::class);
Expand Down Expand Up @@ -89,9 +88,9 @@
'import_functions' => true,
]);

$config->services()
->remove(PhpUnitTestClassRequiresCoversFixer::class);
$config->parallel();
$config->paths([__DIR__]);
$config->skip([__DIR__ . '/.github', __DIR__ . '/build', __DIR__ . '/vendor']);
$config->skip(
[__DIR__ . '/.github', __DIR__ . '/build', __DIR__ . '/vendor', PhpUnitTestClassRequiresCoversFixer::class]
);
};
14 changes: 9 additions & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\ValueObject\PhpVersion;

return static function (RectorConfig $config): void {
$config->import(SetList::DEAD_CODE);
$config->import(LevelSetList::UP_TO_PHP_80);
$config->import(SymfonySetList::SYMFONY_CODE_QUALITY);
$config->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_100);
$config->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
$config->import(PHPUnitSetList::PHPUNIT_EXCEPTION);
$config->import(PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD);
$config->import(PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER);
$config->parallel();
$config->paths([__DIR__ . '/src', __DIR__ . '/tests']);
$config->skip([__DIR__ . '/src/IndefiniteLengthMapObject.php', __DIR__ . '/src/MapObject.php']);
$config->skip(
[
__DIR__ . '/src/IndefiniteLengthMapObject.php',
__DIR__ . '/src/MapObject.php',
PreferPHPUnitThisCallRector::class,
]
);
$config->phpVersion(PhpVersion::PHP_80);
$config->importNames();
$config->importShortClasses();
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractCBORObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace CBOR;

use function chr;
use Stringable;
use function chr;

abstract class AbstractCBORObject implements CBORObject, Stringable
{
Expand Down
18 changes: 9 additions & 9 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
use CBOR\Tag\UnsignedBigIntegerTag;
use CBOR\Tag\UriTag;
use InvalidArgumentException;
use function ord;
use RuntimeException;
use function ord;
use const STR_PAD_LEFT;

final class Decoder implements DecoderInterface
Expand Down Expand Up @@ -150,7 +150,7 @@ private function processInfinite(Stream $stream, int $mt, bool $breakable): CBOR
}

return $object;
case CBORObject::MAJOR_TYPE_TEXT_STRING: //3
case CBORObject::MAJOR_TYPE_TEXT_STRING : //3
$object = IndefiniteLengthTextStringObject::create();
while (! ($it = $this->process($stream, true)) instanceof BreakObject) {
if (! $it instanceof TextStringObject) {
Expand All @@ -162,7 +162,7 @@ private function processInfinite(Stream $stream, int $mt, bool $breakable): CBOR
}

return $object;
case CBORObject::MAJOR_TYPE_LIST: //4
case CBORObject::MAJOR_TYPE_LIST : //4
$object = IndefiniteLengthListObject::create();
$it = $this->process($stream, true);
while (! $it instanceof BreakObject) {
Expand All @@ -171,23 +171,23 @@ private function processInfinite(Stream $stream, int $mt, bool $breakable): CBOR
}

return $object;
case CBORObject::MAJOR_TYPE_MAP: //5
case CBORObject::MAJOR_TYPE_MAP : //5
$object = IndefiniteLengthMapObject::create();
while (! ($it = $this->process($stream, true)) instanceof BreakObject) {
$object->add($it, $this->process($stream, false));
}

return $object;
case CBORObject::MAJOR_TYPE_OTHER_TYPE: //7
case CBORObject::MAJOR_TYPE_OTHER_TYPE : //7
if (! $breakable) {
throw new InvalidArgumentException('Cannot parse the data. No enclosing indefinite.');
}

return BreakObject::create();
case CBORObject::MAJOR_TYPE_UNSIGNED_INTEGER: //0
case CBORObject::MAJOR_TYPE_NEGATIVE_INTEGER: //1
case CBORObject::MAJOR_TYPE_TAG: //6
default:
case CBORObject::MAJOR_TYPE_UNSIGNED_INTEGER : //0
case CBORObject::MAJOR_TYPE_NEGATIVE_INTEGER : //1
case CBORObject::MAJOR_TYPE_TAG : //6
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),
Expand Down
2 changes: 1 addition & 1 deletion src/IndefiniteLengthListObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace CBOR;

use function array_key_exists;
use ArrayAccess;
use ArrayIterator;
use InvalidArgumentException;
use Iterator;
use IteratorAggregate;
use function array_key_exists;

/**
* @phpstan-implements ArrayAccess<int, CBORObject>
Expand Down
2 changes: 1 addition & 1 deletion src/IndefiniteLengthMapObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace CBOR;

use function array_key_exists;
use ArrayAccess;
use ArrayIterator;
use InvalidArgumentException;
use Iterator;
use IteratorAggregate;
use function array_key_exists;

/**
* @phpstan-implements ArrayAccess<int, CBORObject>
Expand Down
2 changes: 1 addition & 1 deletion src/LengthCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace CBOR;

use Brick\Math\BigInteger;
use InvalidArgumentException;
use function chr;
use function count;
use InvalidArgumentException;
use const STR_PAD_LEFT;

final class LengthCalculator
Expand Down
7 changes: 2 additions & 5 deletions src/ListObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace CBOR;

use function array_key_exists;
use ArrayAccess;
use ArrayIterator;
use function count;
use Countable;
use InvalidArgumentException;
use Iterator;
use IteratorAggregate;
use function array_key_exists;
use function count;

/**
* @phpstan-implements ArrayAccess<int, CBORObject>
Expand All @@ -36,9 +36,6 @@ public function __construct(array $data = [])
{
[$additionalInformation, $length] = LengthCalculator::getLengthOfArray($data);
array_map(static function ($item): void {
if (! $item instanceof CBORObject) {
throw new InvalidArgumentException('The list must contain only CBORObject objects.');
}
}, $data);

parent::__construct(self::MAJOR_TYPE, $additionalInformation);
Expand Down
4 changes: 2 additions & 2 deletions src/MapObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace CBOR;

use function array_key_exists;
use ArrayAccess;
use ArrayIterator;
use function count;
use Countable;
use InvalidArgumentException;
use Iterator;
use IteratorAggregate;
use function array_key_exists;
use function count;

/**
* @phpstan-implements ArrayAccess<int, CBORObject>
Expand Down
2 changes: 1 addition & 1 deletion src/OtherObject/DoublePrecisionFloatObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use CBOR\Normalizable;
use CBOR\OtherObject as Base;
use CBOR\Utils;
use const INF;
use InvalidArgumentException;
use const INF;
use const NAN;

final class DoublePrecisionFloatObject extends Base implements Normalizable
Expand Down
2 changes: 1 addition & 1 deletion src/OtherObject/HalfPrecisionFloatObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use CBOR\Normalizable;
use CBOR\OtherObject as Base;
use CBOR\Utils;
use const INF;
use InvalidArgumentException;
use const INF;
use const NAN;

final class HalfPrecisionFloatObject extends Base implements Normalizable
Expand Down
2 changes: 1 addition & 1 deletion src/OtherObject/OtherObjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace CBOR\OtherObject;

use function array_key_exists;
use CBOR\OtherObject;
use InvalidArgumentException;
use function array_key_exists;

class OtherObjectManager implements OtherObjectManagerInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/OtherObject/SimpleObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use CBOR\Normalizable;
use CBOR\OtherObject as Base;
use CBOR\Utils;
use function chr;
use InvalidArgumentException;
use function chr;
use function ord;

final class SimpleObject extends Base implements Normalizable
Expand Down
2 changes: 1 addition & 1 deletion src/OtherObject/SinglePrecisionFloatObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Brick\Math\BigInteger;
use CBOR\OtherObject as Base;
use CBOR\Utils;
use const INF;
use InvalidArgumentException;
use const INF;
use const NAN;

final class SinglePrecisionFloatObject extends Base
Expand Down
4 changes: 2 additions & 2 deletions src/Tag/BigFloatTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use CBOR\Normalizable;
use CBOR\Tag;
use CBOR\UnsignedIntegerObject;
use function count;
use function extension_loaded;
use InvalidArgumentException;
use RuntimeException;
use function count;
use function extension_loaded;

final class BigFloatTag extends Tag implements Normalizable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/DatetimeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use CBOR\Normalizable;
use CBOR\Tag;
use CBOR\TextStringObject;
use const DATE_RFC3339;
use DateTimeImmutable;
use DateTimeInterface;
use InvalidArgumentException;
use const DATE_RFC3339;

/**
* @see \CBOR\Test\Tag\DatetimeTagTest
Expand Down
4 changes: 2 additions & 2 deletions src/Tag/DecimalFractionTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use CBOR\Normalizable;
use CBOR\Tag;
use CBOR\UnsignedIntegerObject;
use function count;
use function extension_loaded;
use InvalidArgumentException;
use RuntimeException;
use function count;
use function extension_loaded;

final class DecimalFractionTag extends Tag implements Normalizable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/TagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace CBOR\Tag;

use function array_key_exists;
use CBOR\CBORObject;
use CBOR\Tag;
use CBOR\Utils;
use InvalidArgumentException;
use function array_key_exists;

final class TagManager implements TagManagerInterface
{
Expand Down
11 changes: 5 additions & 6 deletions tests/ByteStringObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use CBOR\ByteStringObject;
use CBOR\CBORObject;
use CBOR\StringStream;
use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;

Expand Down Expand Up @@ -47,12 +48,10 @@ public function aByteStringObjectCanBeCreated(
static::assertSame($string, $decoded->normalize());
}

public static function getData(): array
public static function getData(): Iterator
{
return [
['Hello', 5, 5, '4548656c6c6f'],
['(。◕‿◕。)', 17, 17, '5128efbda1e29795e280bfe29795efbda129'],
['HelloHelloHelloHelloHello', 24, 25, '581948656c6c6f48656c6c6f48656c6c6f48656c6c6f48656c6c6f'],
];
yield ['Hello', 5, 5, '4548656c6c6f'];
yield ['(。◕‿◕。)', 17, 17, '5128efbda1e29795e280bfe29795efbda129'];
yield ['HelloHelloHelloHelloHello', 24, 25, '581948656c6c6f48656c6c6f48656c6c6f48656c6c6f48656c6c6f'];
}
}
Loading

0 comments on commit 5bd70aa

Please sign in to comment.