From 3813768a29f3c83e5631dbd58ccbe5de56f3f775 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 22 Feb 2026 15:15:14 +0100 Subject: [PATCH 1/4] update dependencies --- CHANGELOG.md | 7 ++++ benchmark/client.php | 2 +- composer.json | 6 +-- fixtures/forever-consumer.php | 2 +- src/Factory.php | 2 +- src/Model/Basic/Message.php | 14 +++---- src/Model/Basic/Message/ContentType.php | 17 ++++---- src/Model/Connection/TuneOk.php | 2 +- .../Format/Timestamp.php | 4 +- src/Transport/Connection.php | 2 +- src/Transport/Connection/Handshake.php | 2 +- src/Transport/Connection/Heartbeat.php | 6 +-- src/Transport/Connection/MessageReader.php | 2 +- src/Transport/Frame.php | 6 +-- src/Transport/Frame/Method.php | 2 +- src/Transport/Frame/Value/Sequence.php | 4 +- .../Frame/Value/SignedLongInteger.php | 17 ++++---- src/Transport/Frame/Value/SignedOctet.php | 17 ++++---- .../Frame/Value/SignedShortInteger.php | 17 ++++---- src/Transport/Frame/Value/Symbol.php | 2 +- src/Transport/Frame/Value/Table.php | 4 +- src/Transport/Frame/Value/Timestamp.php | 16 ++++---- .../Frame/Value/UnsignedLongInteger.php | 17 ++++---- .../Frame/Value/UnsignedLongLongInteger.php | 18 ++++----- src/Transport/Frame/Value/UnsignedOctet.php | 17 ++++---- .../Frame/Value/UnsignedShortInteger.php | 17 ++++---- src/Transport/Protocol.php | 2 +- tests/ClientTest.php | 17 +++++--- tests/Model/Basic/ConsumeTest.php | 4 +- .../Basic/Message/ContentEncodingTest.php | 2 +- tests/Model/Basic/Message/ContentTypeTest.php | 2 +- tests/Model/Basic/MessageTest.php | 6 +-- tests/Model/Connection/MaxChannelsTest.php | 2 +- tests/Model/Connection/MaxFrameSizeTest.php | 2 +- tests/Model/Connection/TuneOkTest.php | 2 +- tests/Model/Exchange/DeclarationTest.php | 14 +++---- tests/Model/Queue/BindingTest.php | 6 +-- tests/Model/Queue/DeclarationTest.php | 18 ++++----- tests/Model/Queue/UnbindingTest.php | 6 +-- .../Transport/Connection/FrameReaderTest.php | 16 ++++---- tests/Transport/ConnectionTest.php | 2 +- tests/Transport/Frame/Value/SequenceTest.php | 4 +- tests/Transport/Frame/Value/TableTest.php | 4 +- tests/Transport/Frame/Value/TimestampTest.php | 12 +++--- tests/Transport/FrameTest.php | 4 +- .../Protocol/ArgumentTranslatorTest.php | 4 +- tests/Transport/Protocol/BasicTest.php | 40 +++++++++---------- tests/Transport/Protocol/ChannelTest.php | 10 ++--- tests/Transport/Protocol/ConnectionTest.php | 23 ++++++----- tests/Transport/Protocol/ExchangeTest.php | 8 ++-- tests/Transport/Protocol/QueueTest.php | 22 +++++----- tests/Transport/Protocol/ReaderTest.php | 4 +- tests/Transport/Protocol/TransactionTest.php | 6 +-- tests/Transport/ProtocolTest.php | 8 ++-- 54 files changed, 244 insertions(+), 228 deletions(-) rename src/{TimeContinuum => Time}/Format/Timestamp.php (71%) diff --git a/CHANGELOG.md b/CHANGELOG.md index babf55be..a7f58b1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires PHP `8.4` +- Requires `innmind/foundation:~2.1` + ## 6.0.0 - 2025-08-08 ### Changed diff --git a/benchmark/client.php b/benchmark/client.php index 81728ce5..11749334 100644 --- a/benchmark/client.php +++ b/benchmark/client.php @@ -8,7 +8,7 @@ Transport\Connection, }; use Innmind\IO\Sockets\Internet\Transport; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\Url\Url; use Innmind\OperatingSystem\Factory as OSFactory; diff --git a/composer.json b/composer.json index 50de1e01..3987ec82 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ "issues": "http://github.com/Innmind/AMQP/issues" }, "require": { - "php": "~8.2", - "innmind/foundation": "^1.7.1", + "php": "~8.4", + "innmind/foundation": "~2.1", "ramsey/uuid": "~4.0" }, "autoload": { @@ -31,7 +31,7 @@ }, "require-dev": { "psr/log": "~3.0", - "innmind/static-analysis": "^1.2.1", + "innmind/static-analysis": "~1.3", "innmind/black-box": "~6.5", "innmind/coding-standard": "~2.0" }, diff --git a/fixtures/forever-consumer.php b/fixtures/forever-consumer.php index ae2738bf..a750c772 100644 --- a/fixtures/forever-consumer.php +++ b/fixtures/forever-consumer.php @@ -10,7 +10,7 @@ }; use Innmind\OperatingSystem\Factory as OSFactory; use Innmind\IO\Sockets\Internet\Transport; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\Url\Url; $os = OSFactory::build(); diff --git a/src/Factory.php b/src/Factory.php index 25d7598d..dfd95ce2 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -6,7 +6,7 @@ use Innmind\OperatingSystem\OperatingSystem; use Innmind\IO\Sockets\Internet\Transport as Socket; use Innmind\Url\Url; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; final class Factory { diff --git a/src/Model/Basic/Message.php b/src/Model/Basic/Message.php index 4acd1625..ab1107af 100644 --- a/src/Model/Basic/Message.php +++ b/src/Model/Basic/Message.php @@ -15,8 +15,8 @@ UserId, AppId, }; -use Innmind\TimeContinuum\{ - PointInTime, +use Innmind\Time\{ + Point, Period, }; use Innmind\Filesystem\File\Content; @@ -51,7 +51,7 @@ final class Message private Maybe $expiration; /** @var Maybe */ private Maybe $id; - /** @var Maybe */ + /** @var Maybe */ private Maybe $timestamp; /** @var Maybe */ private Maybe $type; @@ -92,7 +92,7 @@ private function __construct(Sequence $chunks, int $length) $this->expiration = Maybe::nothing(); /** @var Maybe */ $this->id = Maybe::nothing(); - /** @var Maybe */ + /** @var Maybe */ $this->timestamp = Maybe::nothing(); /** @var Maybe */ $this->type = Maybe::nothing(); @@ -304,7 +304,7 @@ public function withId(Id $id): self } /** - * @return Maybe + * @return Maybe */ #[\NoDiscard] public function timestamp(): Maybe @@ -313,7 +313,7 @@ public function timestamp(): Maybe } #[\NoDiscard] - public function withTimestamp(PointInTime $timestamp): self + public function withTimestamp(Point $timestamp): self { $self = clone $this; $self->timestamp = Maybe::just($timestamp); @@ -380,7 +380,7 @@ public function body(): Str { return $this ->chunks - ->fold(new Concat) + ->fold(Concat::monoid) ->toEncoding(Str\Encoding::ascii); } diff --git a/src/Model/Basic/Message/ContentType.php b/src/Model/Basic/Message/ContentType.php index 52c0bc7f..a1d34680 100644 --- a/src/Model/Basic/Message/ContentType.php +++ b/src/Model/Basic/Message/ContentType.php @@ -4,10 +4,7 @@ namespace Innmind\AMQP\Model\Basic\Message; use Innmind\AMQP\Exception\DomainException; -use Innmind\MediaType\{ - MediaType, - Exception\Exception, -}; +use Innmind\MediaType\MediaType; use Innmind\Immutable\Maybe; /** @@ -21,7 +18,7 @@ final class ContentType private function __construct(MediaType $type) { - $this->value = $type->topLevel().'/'.$type->subType(); + $this->value = $type->topLevel()->name.'/'.$type->subType(); } /** @@ -35,11 +32,11 @@ private function __construct(MediaType $type) #[\NoDiscard] public static function of(string $topLevel, string $subType): self { - try { - return new self(new MediaType($topLevel, $subType)); - } catch (Exception $e) { - throw new DomainException("$topLevel/$subType"); - } + $string = "$topLevel/$subType"; + + return self::maybe($string) + ->attempt(static fn() => new DomainException($string)) + ->unwrap(); } /** diff --git a/src/Model/Connection/TuneOk.php b/src/Model/Connection/TuneOk.php index 20c428e0..99c26daa 100644 --- a/src/Model/Connection/TuneOk.php +++ b/src/Model/Connection/TuneOk.php @@ -3,7 +3,7 @@ namespace Innmind\AMQP\Model\Connection; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; /** * @psalm-immutable diff --git a/src/TimeContinuum/Format/Timestamp.php b/src/Time/Format/Timestamp.php similarity index 71% rename from src/TimeContinuum/Format/Timestamp.php rename to src/Time/Format/Timestamp.php index ed0e444e..899a5462 100644 --- a/src/TimeContinuum/Format/Timestamp.php +++ b/src/Time/Format/Timestamp.php @@ -1,9 +1,9 @@ values ->map(static fn($value) => $value->pack()) - ->fold(new Concat) + ->fold(Concat::monoid) ->toEncoding(Str\Encoding::ascii); return $this->doPack($payload); @@ -183,7 +183,7 @@ private function packHeader(): Str $payload = $this ->values ->map(static fn($value) => $value->pack()) - ->fold(new Concat) + ->fold(Concat::monoid) ->toEncoding(Str\Encoding::ascii); return $this->doPack($payload); @@ -216,7 +216,7 @@ private function doPack(Str $payload): Str $payload, UnsignedOctet::internal(self::end())->pack(), ) - ->fold(new Concat) + ->fold(Concat::monoid) ->toEncoding(Str\Encoding::ascii); } } diff --git a/src/Transport/Frame/Method.php b/src/Transport/Frame/Method.php index 2509c691..2c718c93 100644 --- a/src/Transport/Frame/Method.php +++ b/src/Transport/Frame/Method.php @@ -14,7 +14,7 @@ UnsignedShortInteger, Table, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\Frame; use Innmind\Immutable\{ Maybe, diff --git a/src/Transport/Frame/Value/Sequence.php b/src/Transport/Frame/Value/Sequence.php index 66a6dad5..f42cf46e 100644 --- a/src/Transport/Frame/Value/Sequence.php +++ b/src/Transport/Frame/Value/Sequence.php @@ -7,7 +7,7 @@ Frame\Value, Protocol\ArgumentTranslator, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\Frame; use Innmind\Immutable\{ Sequence as Seq, @@ -102,7 +102,7 @@ public function pack(): Str $value->symbol()->pack(), $value->pack(), )) - ->fold(new Concat) + ->fold(Concat::monoid) ->toEncoding(Str\Encoding::ascii); /** @psalm-suppress InvalidArgument */ $value = UnsignedLongInteger::of($data->length())->pack(); diff --git a/src/Transport/Frame/Value/SignedLongInteger.php b/src/Transport/Frame/Value/SignedLongInteger.php index 91c894b1..d718f529 100644 --- a/src/Transport/Frame/Value/SignedLongInteger.php +++ b/src/Transport/Frame/Value/SignedLongInteger.php @@ -5,9 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -36,7 +35,9 @@ private function __construct(private int $original) */ public static function of(int $value): self { - self::definitionSet()->accept(Integer::of($value)); + $_ = self::definitionSet() + ->accept(Number::of($value)) + ->unwrap(); return new self($value); } @@ -48,10 +49,10 @@ public static function of(int $value): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -106,9 +107,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(-2147483648), - Integer::of(2147483647), + return Set::inclusiveRange( + Number::of(-2147483648), + Number::of(2147483647), ); } } diff --git a/src/Transport/Frame/Value/SignedOctet.php b/src/Transport/Frame/Value/SignedOctet.php index da4aa686..ef767ac2 100644 --- a/src/Transport/Frame/Value/SignedOctet.php +++ b/src/Transport/Frame/Value/SignedOctet.php @@ -5,9 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -38,7 +37,9 @@ private function __construct(private int $original) */ public static function of(int $value): self { - self::definitionSet()->accept(Integer::of($value)); + $_ = self::definitionSet() + ->accept(Number::of($value)) + ->unwrap(); return new self($value); } @@ -50,10 +51,10 @@ public static function of(int $value): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -108,9 +109,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(-128), - Integer::of(127), + return Set::inclusiveRange( + Number::of(-128), + Number::of(127), ); } } diff --git a/src/Transport/Frame/Value/SignedShortInteger.php b/src/Transport/Frame/Value/SignedShortInteger.php index 308771b5..5fab5e7a 100644 --- a/src/Transport/Frame/Value/SignedShortInteger.php +++ b/src/Transport/Frame/Value/SignedShortInteger.php @@ -5,9 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -36,7 +35,9 @@ private function __construct(private int $original) */ public static function of(int $value): self { - self::definitionSet()->accept(Integer::of($value)); + $_ = self::definitionSet() + ->accept(Number::of($value)) + ->unwrap(); return new self($value); } @@ -48,10 +49,10 @@ public static function of(int $value): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -106,9 +107,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(-32768), - Integer::of(32767), + return Set::inclusiveRange( + Number::of(-32768), + Number::of(32767), ); } } diff --git a/src/Transport/Frame/Value/Symbol.php b/src/Transport/Frame/Value/Symbol.php index eacf7542..237e8d84 100644 --- a/src/Transport/Frame/Value/Symbol.php +++ b/src/Transport/Frame/Value/Symbol.php @@ -3,7 +3,7 @@ namespace Innmind\AMQP\Transport\Frame\Value; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\Frame; use Innmind\Immutable\Str; diff --git a/src/Transport/Frame/Value/Table.php b/src/Transport/Frame/Value/Table.php index 4ad4de21..a0dfdf63 100644 --- a/src/Transport/Frame/Value/Table.php +++ b/src/Transport/Frame/Value/Table.php @@ -7,7 +7,7 @@ Frame\Value, Protocol\ArgumentTranslator, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\Frame; use Innmind\Immutable\{ Str, @@ -118,7 +118,7 @@ public function pack(): Str $pair[1]->symbol()->pack(), $pair[1]->pack(), )) - ->fold(new Concat) + ->fold(Concat::monoid) ->toEncoding(Str\Encoding::ascii); /** @psalm-suppress InvalidArgument */ diff --git a/src/Transport/Frame/Value/Timestamp.php b/src/Transport/Frame/Value/Timestamp.php index a018fe39..781f6ac0 100644 --- a/src/Transport/Frame/Value/Timestamp.php +++ b/src/Transport/Frame/Value/Timestamp.php @@ -5,11 +5,11 @@ use Innmind\AMQP\{ Transport\Frame\Value, - TimeContinuum\Format\Timestamp as TimestampFormat, + Time\Format\Timestamp as TimestampFormat, }; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, - PointInTime, + Point, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -20,19 +20,19 @@ }; /** - * @implements Value + * @implements Value * @psalm-immutable */ final class Timestamp implements Value { - private function __construct(private PointInTime $original) + private function __construct(private Point $original) { } /** * @psalm-pure */ - public static function of(PointInTime $point): self + public static function of(Point $point): self { return new self($point); } @@ -45,7 +45,7 @@ public static function of(PointInTime $point): self public static function wrap(mixed $value): Either { return Maybe::of($value) - ->keep(Instance::of(PointInTime::class)) + ->keep(Instance::of(Point::class)) ->either() ->map(static fn($point) => new self($point)) ->leftMap(static fn(): mixed => $value); @@ -77,7 +77,7 @@ public static function frame(Clock $clock): Frame } #[\Override] - public function original(): PointInTime + public function original(): Point { return $this->original; } diff --git a/src/Transport/Frame/Value/UnsignedLongInteger.php b/src/Transport/Frame/Value/UnsignedLongInteger.php index 9c327c46..1d19a531 100644 --- a/src/Transport/Frame/Value/UnsignedLongInteger.php +++ b/src/Transport/Frame/Value/UnsignedLongInteger.php @@ -5,9 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -47,7 +46,9 @@ public static function internal(int $value): self */ public static function of(int $value): self { - self::definitionSet()->accept(Integer::of($value)); + $_ = self::definitionSet() + ->accept(Number::of($value)) + ->unwrap(); return new self($value); } @@ -59,10 +60,10 @@ public static function of(int $value): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -117,9 +118,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(0), - Integer::of(4294967295), + return Set::inclusiveRange( + Number::of(0), + Number::of(4294967295), ); } } diff --git a/src/Transport/Frame/Value/UnsignedLongLongInteger.php b/src/Transport/Frame/Value/UnsignedLongLongInteger.php index daf130b2..5d81e8f6 100644 --- a/src/Transport/Frame/Value/UnsignedLongLongInteger.php +++ b/src/Transport/Frame/Value/UnsignedLongLongInteger.php @@ -5,10 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, - Algebra, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -48,7 +46,9 @@ public static function internal(int $value): self */ public static function of(int $value): self { - self::definitionSet()->accept(Integer::of($value)); + $_ = self::definitionSet() + ->accept(Number::of($value)) + ->unwrap(); return new self($value); } @@ -60,10 +60,10 @@ public static function of(int $value): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -118,9 +118,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(0), - Algebra\Value::infinite, + return Set::inclusiveRange( + Number::of(0), + Number::infinite(), ); } } diff --git a/src/Transport/Frame/Value/UnsignedOctet.php b/src/Transport/Frame/Value/UnsignedOctet.php index dd64ee23..20013f86 100644 --- a/src/Transport/Frame/Value/UnsignedOctet.php +++ b/src/Transport/Frame/Value/UnsignedOctet.php @@ -5,9 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -49,7 +48,9 @@ public static function internal(int $octet): self */ public static function of(int $octet): self { - self::definitionSet()->accept(Integer::of($octet)); + $_ = self::definitionSet() + ->accept(Number::of($octet)) + ->unwrap(); return new self($octet); } @@ -61,10 +62,10 @@ public static function of(int $octet): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -119,9 +120,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(0), - Integer::of(255), + return Set::inclusiveRange( + Number::of(0), + Number::of(255), ); } } diff --git a/src/Transport/Frame/Value/UnsignedShortInteger.php b/src/Transport/Frame/Value/UnsignedShortInteger.php index 5fdade1c..d9560a47 100644 --- a/src/Transport/Frame/Value/UnsignedShortInteger.php +++ b/src/Transport/Frame/Value/UnsignedShortInteger.php @@ -5,9 +5,8 @@ use Innmind\AMQP\Transport\Frame\Value; use Innmind\Math\{ - Algebra\Integer, + Algebra\Number, DefinitionSet\Set, - DefinitionSet\Range, }; use Innmind\IO\Frame; use Innmind\Immutable\{ @@ -47,7 +46,9 @@ public static function internal(int $value): self */ public static function of(int $value): self { - self::definitionSet()->accept(Integer::of($value)); + $_ = self::definitionSet() + ->accept(Number::of($value)) + ->unwrap(); return new self($value); } @@ -59,10 +60,10 @@ public static function of(int $value): self */ public static function wrap(mixed $value): Either { - /** @psalm-suppress ArgumentTypeCoercion */ + /** @psalm-suppress InvalidArgument */ return Maybe::of($value) ->filter(\is_int(...)) - ->map(Integer::of(...)) + ->map(Number::of(...)) ->filter(self::definitionSet()->contains(...)) ->either() ->map(static fn($int) => new self($int->value())) @@ -117,9 +118,9 @@ public function pack(): Str */ public static function definitionSet(): Set { - return Range::inclusive( - Integer::of(0), - Integer::of(65535), + return Set::inclusiveRange( + Number::of(0), + Number::of(65535), ); } } diff --git a/src/Transport/Protocol.php b/src/Transport/Protocol.php index 456c67f7..0d1edbb3 100644 --- a/src/Transport/Protocol.php +++ b/src/Transport/Protocol.php @@ -21,7 +21,7 @@ Frame\Value\ShortString, Frame\Value, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\Frame; use Innmind\Immutable\Sequence; diff --git a/tests/ClientTest.php b/tests/ClientTest.php index a22b7832..ad510b64 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -21,12 +21,12 @@ Command\Transaction, Model\Exchange\Type, Model\Basic\Message, - TimeContinuum\Format\Timestamp as TimestampFormat, + Time\Format\Timestamp as TimestampFormat, Exception\BasicGetNotCancellable, }; use Innmind\IO\Sockets\Internet\Transport; use Innmind\OperatingSystem\Factory as OSFactory; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Period, Format, }; @@ -158,7 +158,7 @@ public function testCancelingAGetThrowsAnException() { $this->expectException(BasicGetNotCancellable::class); - $this + $_ = $this ->client ->with(DeclareExchange::of('foo', Type::direct)) ->with(DeclareQueue::of('bar')) @@ -738,8 +738,12 @@ public function testSignals($signal) ->withWorkingDirectory(Path::of(\getcwd())), ) ->unwrap(); - $this->os->process()->halt(Period::millisecond(100)); - $this + $_ = $this + ->os + ->process() + ->halt(Period::millisecond(100)) + ->unwrap(); + $_ = $this ->os ->control() ->processes() @@ -749,7 +753,8 @@ public function testSignals($signal) static fn() => null, ), $signal, - ); + ) + ->unwrap(); $this->assertSame( 1, diff --git a/tests/Model/Basic/ConsumeTest.php b/tests/Model/Basic/ConsumeTest.php index 6fc2a225..724c59ea 100644 --- a/tests/Model/Basic/ConsumeTest.php +++ b/tests/Model/Basic/ConsumeTest.php @@ -21,7 +21,7 @@ public function testInterface() $this->assertSame('queue', $command->queue()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); $this->assertNull($command->consumerTag()->match( static fn($tag) => $tag, static fn() => null, @@ -140,6 +140,6 @@ public function testThrowWhenNotWaitingResponseWithAutoGeneratedConsumerTag() { $this->expectException(AutoGeneratedConsumerTagRequireServerResponse::class); - Consume::of('queue')->dontWait(); + $_ = Consume::of('queue')->dontWait(); } } diff --git a/tests/Model/Basic/Message/ContentEncodingTest.php b/tests/Model/Basic/Message/ContentEncodingTest.php index 0b709c10..1d2c8e7e 100644 --- a/tests/Model/Basic/Message/ContentEncodingTest.php +++ b/tests/Model/Basic/Message/ContentEncodingTest.php @@ -25,6 +25,6 @@ public function testThrowWhenInvalidContentEncoding() { $this->expectException(DomainException::class); - ContentEncoding::of('foo bar'); + $_ = ContentEncoding::of('foo bar'); } } diff --git a/tests/Model/Basic/Message/ContentTypeTest.php b/tests/Model/Basic/Message/ContentTypeTest.php index d5732d72..15fdf190 100644 --- a/tests/Model/Basic/Message/ContentTypeTest.php +++ b/tests/Model/Basic/Message/ContentTypeTest.php @@ -28,6 +28,6 @@ public function testThrowWhenInvalidContentType() { $this->expectException(DomainException::class); - ContentType::of('foo', 'json'); + $_ = ContentType::of('foo', 'json'); } } diff --git a/tests/Model/Basic/MessageTest.php b/tests/Model/Basic/MessageTest.php index f22f0ac8..b0475565 100644 --- a/tests/Model/Basic/MessageTest.php +++ b/tests/Model/Basic/MessageTest.php @@ -16,8 +16,8 @@ Message\Type, Message\UserId, }; -use Innmind\TimeContinuum\{ - PointInTime, +use Innmind\Time\{ + Point, Period, }; use Innmind\Immutable\{ @@ -237,7 +237,7 @@ public function testTimestamp() { $message = Message::of(Str::of('')); $message2 = $message->withTimestamp( - $expected = PointInTime::now(), + $expected = Point::now(), ); $this->assertInstanceOf(Message::class, $message2); diff --git a/tests/Model/Connection/MaxChannelsTest.php b/tests/Model/Connection/MaxChannelsTest.php index a91f29af..894d7e26 100644 --- a/tests/Model/Connection/MaxChannelsTest.php +++ b/tests/Model/Connection/MaxChannelsTest.php @@ -122,7 +122,7 @@ public function testThrowWhenVerifyingNumberAboveMaxAllowed(): BlackBox\Proof $above = $allowed + $extraNumber; try { - $max->verify($above)->unwrap(); + $_ = $max->verify($above)->unwrap(); $this->fail('it should throw'); } catch (FrameChannelExceedAllowedChannelNumber $e) { $this->assertSame( diff --git a/tests/Model/Connection/MaxFrameSizeTest.php b/tests/Model/Connection/MaxFrameSizeTest.php index fe823194..9899868b 100644 --- a/tests/Model/Connection/MaxFrameSizeTest.php +++ b/tests/Model/Connection/MaxFrameSizeTest.php @@ -124,7 +124,7 @@ public function testThrowWhenVerifyingSizeAboveMaxAllowed(): BlackBox\Proof $this->expectException(FrameExceedAllowedSize::class); $this->expectExceptionMessage("Max frame size can be $allowed but got $above"); - $max->verify($above)->unwrap(); + $_ = $max->verify($above)->unwrap(); }); } diff --git a/tests/Model/Connection/TuneOkTest.php b/tests/Model/Connection/TuneOkTest.php index c17c4cb2..e6cba85f 100644 --- a/tests/Model/Connection/TuneOkTest.php +++ b/tests/Model/Connection/TuneOkTest.php @@ -8,7 +8,7 @@ MaxChannels, MaxFrameSize, }; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\BlackBox\PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\Group; diff --git a/tests/Model/Exchange/DeclarationTest.php b/tests/Model/Exchange/DeclarationTest.php index bdaf695d..a2b274ab 100644 --- a/tests/Model/Exchange/DeclarationTest.php +++ b/tests/Model/Exchange/DeclarationTest.php @@ -28,7 +28,7 @@ public function testPassive() $this->assertFalse($command->isAutoDeleted()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -45,7 +45,7 @@ public function testDurable() $this->assertFalse($command->isAutoDeleted()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -62,7 +62,7 @@ public function testTemporary() $this->assertFalse($command->isAutoDeleted()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -79,7 +79,7 @@ public function testAutoDeleted() $this->assertTrue($command->isAutoDeleted()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -101,7 +101,7 @@ public function testThrowWhenNotWaitingPassiveDeclaration() { $this->expectException(NotWaitingPassiveDeclarationDoesNothing::class); - Declaration::passive('foo', Type::direct)->dontWait(); + $_ = Declaration::passive('foo', Type::direct)->dontWait(); } #[Group('ci')] @@ -126,8 +126,8 @@ public function testWithArgument() $this->assertInstanceOf(Declaration::class, $command2); $this->assertNotSame($command2, $command); - $this->assertCount(0, $command->arguments()); - $this->assertCount(1, $command2->arguments()); + $this->assertSame(0, $command->arguments()->size()); + $this->assertSame(1, $command2->arguments()->size()); $this->assertSame([42], $command2->arguments()->get('bar')->match( static fn($argument) => $argument, static fn() => null, diff --git a/tests/Model/Queue/BindingTest.php b/tests/Model/Queue/BindingTest.php index 14dc9317..36882b22 100644 --- a/tests/Model/Queue/BindingTest.php +++ b/tests/Model/Queue/BindingTest.php @@ -21,7 +21,7 @@ public function testInterface() $this->assertSame('baz', $command->routingKey()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -59,8 +59,8 @@ public function testWithArgument() $this->assertInstanceOf(Binding::class, $command2); $this->assertNotSame($command2, $command); - $this->assertCount(0, $command->arguments()); - $this->assertCount(1, $command2->arguments()); + $this->assertSame(0, $command->arguments()->size()); + $this->assertSame(1, $command2->arguments()->size()); $this->assertSame([42], $command2->arguments()->get('f')->match( static fn($argument) => $argument, static fn() => null, diff --git a/tests/Model/Queue/DeclarationTest.php b/tests/Model/Queue/DeclarationTest.php index 76ef8a9e..789e3ec5 100644 --- a/tests/Model/Queue/DeclarationTest.php +++ b/tests/Model/Queue/DeclarationTest.php @@ -32,7 +32,7 @@ public function testPassive() $this->assertFalse($command->isExclusive()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -52,7 +52,7 @@ public function testDurable() $this->assertFalse($command->isExclusive()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -72,7 +72,7 @@ public function testTemporary() $this->assertFalse($command->isExclusive()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -92,7 +92,7 @@ public function testAutoDelete() $this->assertFalse($command->isExclusive()); $this->assertTrue($command->shouldWait()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -114,7 +114,7 @@ public function testThrowWhenUsingExclusivePassiveDeclaration() { $this->expectException(ExclusivePassiveDeclarationNotAllowed::class); - Declaration::passive('foo')->exclusive(); + $_ = Declaration::passive('foo')->exclusive(); } #[Group('ci')] @@ -149,7 +149,7 @@ public function testThrowWhenNotWaitingPassiveDeclaration() { $this->expectException(NotWaitingPassiveDeclarationDoesNothing::class); - Declaration::passive('foo')->dontWait(); + $_ = Declaration::passive('foo')->dontWait(); } #[Group('ci')] @@ -199,7 +199,7 @@ public function testThrowWhenAskingForAutoGeneratedNameOnPassiveDeclaration() { $this->expectException(PassiveQueueDeclarationMustHaveAName::class); - Declaration::passive('foo')->withAutoGeneratedName(); + $_ = Declaration::passive('foo')->withAutoGeneratedName(); } #[Group('ci')] @@ -211,8 +211,8 @@ public function testWithArgument() $this->assertInstanceOf(Declaration::class, $command2); $this->assertNotSame($command2, $command); - $this->assertCount(0, $command->arguments()); - $this->assertCount(1, $command2->arguments()); + $this->assertSame(0, $command->arguments()->size()); + $this->assertSame(1, $command2->arguments()->size()); $this->assertSame([42], $command2->arguments()->get('foo')->match( static fn($argument) => $argument, static fn() => null, diff --git a/tests/Model/Queue/UnbindingTest.php b/tests/Model/Queue/UnbindingTest.php index 2a876d3a..b1b520b5 100644 --- a/tests/Model/Queue/UnbindingTest.php +++ b/tests/Model/Queue/UnbindingTest.php @@ -20,7 +20,7 @@ public function testInterface() $this->assertSame('bar', $command->queue()); $this->assertSame('baz', $command->routingKey()); $this->assertInstanceOf(Map::class, $command->arguments()); - $this->assertCount(0, $command->arguments()); + $this->assertSame(0, $command->arguments()->size()); } #[Group('ci')] @@ -32,8 +32,8 @@ public function testWithArgument() $this->assertInstanceOf(Unbinding::class, $command2); $this->assertNotSame($command2, $command); - $this->assertCount(0, $command->arguments()); - $this->assertCount(1, $command2->arguments()); + $this->assertSame(0, $command->arguments()->size()); + $this->assertSame(1, $command2->arguments()->size()); $this->assertSame([42], $command2->arguments()->get('f')->match( static fn($argument) => $argument, static fn() => null, diff --git a/tests/Transport/Connection/FrameReaderTest.php b/tests/Transport/Connection/FrameReaderTest.php index 7ffdb8c4..9bb28180 100644 --- a/tests/Transport/Connection/FrameReaderTest.php +++ b/tests/Transport/Connection/FrameReaderTest.php @@ -31,12 +31,12 @@ Model\Basic\Message\Type as MessageType, Model\Basic\Message\UserId, Model\Connection\MaxFrameSize, - TimeContinuum\Format\Timestamp as TimestampFormat, + Time\Format\Timestamp as TimestampFormat, }; use Innmind\IO\IO; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Period, - PointInTime, + Point, Clock, }; use Innmind\Immutable\{ @@ -196,7 +196,7 @@ public function testReadHeader() ->withReplyTo(ReplyTo::of('reply')) ->withExpiration(Period::second(1)) ->withId(Id::of('id')) - ->withTimestamp($now = PointInTime::now()) + ->withTimestamp($now = Point::now()) ->withType(MessageType::of('type')) ->withUserId(UserId::of('guest')) ->withAppId(AppId::of('webcrawler')), @@ -227,7 +227,7 @@ public function testReadHeader() $this->assertInstanceOf(Frame::class, $frame); $this->assertSame(Type::header, $frame->type()); $this->assertSame(1, $frame->channel()->toInt()); - $this->assertCount(15, $frame->values()); + $this->assertSame(15, $frame->values()->size()); $this->assertInstanceOf( UnsignedLongLongInteger::class, $frame->values()->first()->match( @@ -299,8 +299,8 @@ public function testReadHeader() static fn() => null, ), ); - $this->assertCount(1, $frame->values()->get(4)->match( - static fn($value) => $value->original(), + $this->assertSame(1, $frame->values()->get(4)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame( @@ -489,7 +489,7 @@ public function testReadBody() $this->assertInstanceOf(Frame::class, $frame); $this->assertSame(Type::body, $frame->type()); $this->assertSame(1, $frame->channel()->toInt()); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); $this->assertSame('foobar', $frame->content()->match( static fn($value) => $value->toString(), static fn() => null, diff --git a/tests/Transport/ConnectionTest.php b/tests/Transport/ConnectionTest.php index ab9a8bcf..e91709aa 100644 --- a/tests/Transport/ConnectionTest.php +++ b/tests/Transport/ConnectionTest.php @@ -14,7 +14,7 @@ }; use Innmind\IO\Sockets\Internet\Transport; use Innmind\Url\Url; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\OperatingSystem\Factory; use Innmind\Immutable\{ Sequence, diff --git a/tests/Transport/Frame/Value/SequenceTest.php b/tests/Transport/Frame/Value/SequenceTest.php index 21528737..47d34633 100644 --- a/tests/Transport/Frame/Value/SequenceTest.php +++ b/tests/Transport/Frame/Value/SequenceTest.php @@ -8,7 +8,7 @@ Transport\Frame\Value\LongString, Transport\Frame\Value, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\IO; use Innmind\Immutable\{ Sequence as Seq, @@ -62,7 +62,7 @@ public function testFromStream($string, $expected) ); $this->assertInstanceOf(Sequence::class, $value); - $this->assertCount(\count($expected), $value->original()); + $this->assertSame(\count($expected), $value->original()->size()); foreach ($expected as $i => $v) { $this->assertInstanceOf( diff --git a/tests/Transport/Frame/Value/TableTest.php b/tests/Transport/Frame/Value/TableTest.php index f9f52f53..ab9feed2 100644 --- a/tests/Transport/Frame/Value/TableTest.php +++ b/tests/Transport/Frame/Value/TableTest.php @@ -9,7 +9,7 @@ Transport\Frame\Value\LongString, Transport\Frame\Value, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\IO; use Innmind\Immutable\{ Map, @@ -65,7 +65,7 @@ public function testFromStream($string, $expected) ); $this->assertInstanceOf(Table::class, $value); - $this->assertCount($expected->size(), $value->original()); + $this->assertSame($expected->size(), $value->original()->size()); foreach ($expected as $i => $v) { $this->assertInstanceOf( diff --git a/tests/Transport/Frame/Value/TimestampTest.php b/tests/Transport/Frame/Value/TimestampTest.php index 2957a297..cccd5288 100644 --- a/tests/Transport/Frame/Value/TimestampTest.php +++ b/tests/Transport/Frame/Value/TimestampTest.php @@ -7,8 +7,8 @@ Value\Timestamp, Value, }; -use Innmind\TimeContinuum\{ - PointInTime, +use Innmind\Time\{ + Point, Clock, }; use Innmind\IO\IO; @@ -24,7 +24,7 @@ public function testInterface() { $this->assertInstanceOf( Value::class, - Timestamp::of(PointInTime::now()), + Timestamp::of(Point::now()), ); } @@ -32,7 +32,7 @@ public function testInterface() #[Group('local')] public function testStringCast() { - $value = Timestamp::of($now = PointInTime::now()); + $value = Timestamp::of($now = Point::now()); $this->assertSame(\pack('J', \time()), $value->pack()->toString()); $this->assertSame($now, $value->original()); } @@ -58,10 +58,10 @@ public function testFromStream() ); $this->assertInstanceOf(Timestamp::class, $value); - $this->assertInstanceOf(PointInTime::class, $value->original()); + $this->assertInstanceOf(Point::class, $value->original()); $this->assertTrue( $value->original()->equals( - PointInTime::at(new \DateTimeImmutable( + Point::at(new \DateTimeImmutable( \date(\DateTime::ATOM, $time), )), ), diff --git a/tests/Transport/FrameTest.php b/tests/Transport/FrameTest.php index 5ea3250f..cf24c667 100644 --- a/tests/Transport/FrameTest.php +++ b/tests/Transport/FrameTest.php @@ -77,7 +77,7 @@ public function testBody() $this->assertInstanceOf(Frame::class, $frame); $this->assertSame($channel, $frame->channel()); $this->assertInstanceOf(Sequence::class, $frame->values()); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); $this->assertSame($text, $frame->content()->match( static fn($value) => $value, static fn() => null, @@ -98,7 +98,7 @@ public function testHeartbeat() $this->assertInstanceOf(Channel::class, $frame->channel()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertInstanceOf(Sequence::class, $frame->values()); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); $this->assertSame( \chr(8).\pack('n', 0).\pack('N', 0).\chr(0xCE), $frame->pack()->toString(), diff --git a/tests/Transport/Protocol/ArgumentTranslatorTest.php b/tests/Transport/Protocol/ArgumentTranslatorTest.php index 2ede4505..8c939bc1 100644 --- a/tests/Transport/Protocol/ArgumentTranslatorTest.php +++ b/tests/Transport/Protocol/ArgumentTranslatorTest.php @@ -17,7 +17,7 @@ PHPUnit\Framework\TestCase, Set, }; -use Fixtures\Innmind\TimeContinuum\PointInTime; +use Fixtures\Innmind\Time\Point; use PHPUnit\Framework\Attributes\Group; class ArgumentTranslatorTest extends TestCase @@ -46,7 +46,7 @@ public function testWideRangeOfValues() { $primitive = Set::either( Set::integers(), - PointInTime::any(), + Point::any(), ); $this diff --git a/tests/Transport/Protocol/BasicTest.php b/tests/Transport/Protocol/BasicTest.php index 1d8ea792..9970c7c4 100644 --- a/tests/Transport/Protocol/BasicTest.php +++ b/tests/Transport/Protocol/BasicTest.php @@ -39,8 +39,8 @@ Model\Basic\Message\UserId, Model\Connection\MaxFrameSize, }; -use Innmind\TimeContinuum\{ - PointInTime, +use Innmind\Time\{ + Point, Period, }; use Innmind\Immutable\{ @@ -76,7 +76,7 @@ public function testAck() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 80))); - $this->assertCount(2, $frame->values()); + $this->assertSame(2, $frame->values()->size()); $this->assertInstanceOf( UnsignedLongLongInteger::class, $frame->values()->get(0)->match( @@ -133,7 +133,7 @@ public function testCancel() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 30))); - $this->assertCount(2, $frame->values()); + $this->assertSame(2, $frame->values()->size()); $this->assertInstanceOf(ShortString::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, @@ -189,7 +189,7 @@ public function testConsume() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 20))); - $this->assertCount(5, $frame->values()); + $this->assertSame(5, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -232,8 +232,8 @@ public function testConsume() static fn($value) => $value, static fn() => null, )); - $this->assertCount(2, $frame->values()->get(4)->match( - static fn($value) => $value->original(), + $this->assertSame(2, $frame->values()->get(4)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame(24, $frame->values()->get(4)->match( @@ -347,7 +347,7 @@ public function testGet() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 70))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -407,7 +407,7 @@ public function testPublish() ); $this->assertInstanceOf(Sequence::class, $frames); - $this->assertCount(3, $frames); + $this->assertSame(3, $frames->size()); $frame = $frames->first()->match( static fn($frame) => $frame, @@ -416,7 +416,7 @@ public function testPublish() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 40))); - $this->assertCount(4, $frame->values()); + $this->assertSame(4, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -462,7 +462,7 @@ public function testPublish() ); $this->assertSame(Type::header, $frame->type()); $this->assertSame($channel, $frame->channel()); - $this->assertCount(2, $frame->values()); + $this->assertSame(2, $frame->values()->size()); $this->assertInstanceOf( UnsignedLongLongInteger::class, $frame->values()->get(0)->match( @@ -512,7 +512,7 @@ public function testPublishWithChunkedMessage() ); $this->assertInstanceOf(Sequence::class, $frames); - $this->assertCount(4, $frames); + $this->assertSame(4, $frames->size()); $frame = $frames->get(1)->match( static fn($frame) => $frame, @@ -573,7 +573,7 @@ public function testPublishWithProperties() ->withReplyTo(ReplyTo::of('reply')) ->withExpiration(Period::second(1)) ->withId(Id::of('id')) - ->withTimestamp($now = PointInTime::now()) + ->withTimestamp($now = Point::now()) ->withType(MessageType::of('type')) ->withUserId(UserId::of('guest')) ->withAppId(AppId::of('webcrawler')), @@ -582,7 +582,7 @@ public function testPublishWithProperties() ); $this->assertInstanceOf(Sequence::class, $frames); - $this->assertCount(3, $frames); + $this->assertSame(3, $frames->size()); $frame = $frames->get(1)->match( static fn($frame) => $frame, @@ -590,7 +590,7 @@ public function testPublishWithProperties() ); $this->assertSame(Type::header, $frame->type()); $this->assertSame($channel, $frame->channel()); - $this->assertCount(15, $frame->values()); + $this->assertSame(15, $frame->values()->size()); $this->assertInstanceOf( UnsignedLongLongInteger::class, $frame->values()->get(0)->match( @@ -662,8 +662,8 @@ public function testPublishWithProperties() static fn() => null, ), ); - $this->assertCount(1, $frame->values()->get(4)->match( - static fn($value) => $value->original(), + $this->assertSame(1, $frame->values()->get(4)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame( @@ -919,7 +919,7 @@ public function testQos() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 10))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( UnsignedLongInteger::class, $frame->values()->get(0)->match( @@ -987,7 +987,7 @@ public function testRecover() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 110))); - $this->assertCount(1, $frame->values()); + $this->assertSame(1, $frame->values()->size()); $this->assertInstanceOf(Bits::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, @@ -1033,7 +1033,7 @@ public function testReject() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(60, 90))); - $this->assertCount(2, $frame->values()); + $this->assertSame(2, $frame->values()->size()); $this->assertInstanceOf( UnsignedLongLongInteger::class, $frame->values()->get(0)->match( diff --git a/tests/Transport/Protocol/ChannelTest.php b/tests/Transport/Protocol/ChannelTest.php index 1a73bb96..cfda9268 100644 --- a/tests/Transport/Protocol/ChannelTest.php +++ b/tests/Transport/Protocol/ChannelTest.php @@ -36,7 +36,7 @@ public function testOpen() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(20, 10))); - $this->assertCount(1, $frame->values()); + $this->assertSame(1, $frame->values()->size()); $this->assertInstanceOf(ShortString::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, @@ -63,7 +63,7 @@ public function testFlow() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(20, 20))); - $this->assertCount(1, $frame->values()); + $this->assertSame(1, $frame->values()->size()); $this->assertInstanceOf(Bits::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, @@ -109,7 +109,7 @@ public function testFlowOk() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(20, 21))); - $this->assertCount(1, $frame->values()); + $this->assertSame(1, $frame->values()->size()); $this->assertInstanceOf(Bits::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, @@ -155,7 +155,7 @@ public function testClose() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(20, 40))); - $this->assertCount(4, $frame->values()); + $this->assertSame(4, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -239,6 +239,6 @@ public function testCloseOk() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(20, 41))); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); } } diff --git a/tests/Transport/Protocol/ConnectionTest.php b/tests/Transport/Protocol/ConnectionTest.php index 76fc3287..f1bfe2aa 100644 --- a/tests/Transport/Protocol/ConnectionTest.php +++ b/tests/Transport/Protocol/ConnectionTest.php @@ -22,7 +22,7 @@ Model\Connection\MaxChannels, Model\Connection\MaxFrameSize, }; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\Url\{ Authority\UserInformation\User, Authority\UserInformation\Password, @@ -51,13 +51,13 @@ public function testStartOk() $this->assertSame(Type::method, $frame->type()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertTrue($frame->is(Method::of(10, 11))); - $this->assertCount(4, $frame->values()); + $this->assertSame(4, $frame->values()->size()); $this->assertInstanceOf(Table::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, )); - $this->assertCount(6, $frame->values()->get(0)->match( - static fn($value) => $value->original(), + $this->assertSame(6, $frame->values()->get(0)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame( @@ -150,7 +150,7 @@ public function testStartOk() ->original() ->toString(), ); - $this->assertCount( + $this->assertSame( 5, $frame ->values() @@ -165,7 +165,8 @@ public function testStartOk() static fn($value) => $value, static fn() => null, ) - ->original(), + ->original() + ->size(), ); $this->assertTrue( $frame @@ -348,7 +349,7 @@ public function testSecureOk() $this->assertSame(Type::method, $frame->type()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertTrue($frame->is(Method::of(10, 21))); - $this->assertCount(1, $frame->values()); + $this->assertSame(1, $frame->values()->size()); $this->assertInstanceOf(LongString::class, $frame->values()->get(0)->match( static fn($value) => $value, static fn() => null, @@ -381,7 +382,7 @@ public function testTuneOk() $this->assertSame(Type::method, $frame->type()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertTrue($frame->is(Method::of(10, 31))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -432,7 +433,7 @@ public function testOpen() $this->assertSame(Type::method, $frame->type()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertTrue($frame->is(Method::of(10, 40))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( ShortString::class, $frame->values()->get(0)->match( @@ -486,7 +487,7 @@ public function testClose() $this->assertSame(Type::method, $frame->type()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertTrue($frame->is(Method::of(10, 50))); - $this->assertCount(4, $frame->values()); + $this->assertSame(4, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -570,6 +571,6 @@ public function testCloseOk() $this->assertSame(Type::method, $frame->type()); $this->assertSame(0, $frame->channel()->toInt()); $this->assertTrue($frame->is(Method::of(10, 51))); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); } } diff --git a/tests/Transport/Protocol/ExchangeTest.php b/tests/Transport/Protocol/ExchangeTest.php index 7a86576e..04ca095a 100644 --- a/tests/Transport/Protocol/ExchangeTest.php +++ b/tests/Transport/Protocol/ExchangeTest.php @@ -47,7 +47,7 @@ public function testDeclare() $this->assertSame(Frame\Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(40, 10))); - $this->assertCount(5, $frame->values()); + $this->assertSame(5, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -90,8 +90,8 @@ public function testDeclare() static fn($value) => $value, static fn() => null, )); - $this->assertCount(2, $frame->values()->get(4)->match( - static fn($value) => $value->original(), + $this->assertSame(2, $frame->values()->get(4)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame(24, $frame->values()->get(4)->match( @@ -190,7 +190,7 @@ public function testDeletion() $this->assertSame(Frame\Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(40, 20))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( diff --git a/tests/Transport/Protocol/QueueTest.php b/tests/Transport/Protocol/QueueTest.php index 14b2dc21..729e7eb8 100644 --- a/tests/Transport/Protocol/QueueTest.php +++ b/tests/Transport/Protocol/QueueTest.php @@ -50,7 +50,7 @@ public function testDeclare() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(50, 10))); - $this->assertCount(4, $frame->values()); + $this->assertSame(4, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -85,8 +85,8 @@ public function testDeclare() static fn($value) => $value, static fn() => null, )); - $this->assertCount(2, $frame->values()->get(3)->match( - static fn($value) => $value->original(), + $this->assertSame(2, $frame->values()->get(3)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame(24, $frame->values()->get(3)->match( @@ -234,7 +234,7 @@ public function testDelete() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(50, 40))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -333,7 +333,7 @@ public function testBind() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(50, 20))); - $this->assertCount(6, $frame->values()); + $this->assertSame(6, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -384,8 +384,8 @@ public function testBind() static fn($value) => $value, static fn() => null, )); - $this->assertCount(2, $frame->values()->get(5)->match( - static fn($value) => $value->original(), + $this->assertSame(2, $frame->values()->get(5)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame(24, $frame->values()->get(5)->match( @@ -438,7 +438,7 @@ public function testUnbind() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(50, 50))); - $this->assertCount(5, $frame->values()); + $this->assertSame(5, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( @@ -478,8 +478,8 @@ public function testUnbind() static fn($value) => $value, static fn() => null, )); - $this->assertCount(2, $frame->values()->get(4)->match( - static fn($value) => $value->original(), + $this->assertSame(2, $frame->values()->get(4)->match( + static fn($value) => $value->original()->size(), static fn() => null, )); $this->assertSame(24, $frame->values()->get(4)->match( @@ -514,7 +514,7 @@ public function testPurge() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(50, 30))); - $this->assertCount(3, $frame->values()); + $this->assertSame(3, $frame->values()->size()); $this->assertInstanceOf( UnsignedShortInteger::class, $frame->values()->get(0)->match( diff --git a/tests/Transport/Protocol/ReaderTest.php b/tests/Transport/Protocol/ReaderTest.php index 655b5775..24b05fa8 100644 --- a/tests/Transport/Protocol/ReaderTest.php +++ b/tests/Transport/Protocol/ReaderTest.php @@ -14,7 +14,7 @@ Frame\Value\Table, Frame\Value\LongString }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\IO\IO; use Innmind\Immutable\{ Str, @@ -56,7 +56,7 @@ public function testInvokation($method, $arguments) ); $this->assertInstanceOf(Sequence::class, $stream); - $this->assertCount(\count($arguments), $stream); + $this->assertSame(\count($arguments), $stream->size()); foreach ($arguments as $i => $argument) { $this->assertInstanceOf(\get_class($argument), $stream->get($i)->match( diff --git a/tests/Transport/Protocol/TransactionTest.php b/tests/Transport/Protocol/TransactionTest.php index d2ff1128..6fca2b32 100644 --- a/tests/Transport/Protocol/TransactionTest.php +++ b/tests/Transport/Protocol/TransactionTest.php @@ -30,7 +30,7 @@ public function testSelect() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(90, 10))); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); } #[Group('ci')] @@ -48,7 +48,7 @@ public function testCommit() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(90, 20))); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); } #[Group('ci')] @@ -66,6 +66,6 @@ public function testRollback() $this->assertSame(Type::method, $frame->type()); $this->assertSame($channel, $frame->channel()); $this->assertTrue($frame->is(Method::of(90, 30))); - $this->assertCount(0, $frame->values()); + $this->assertSame(0, $frame->values()->size()); } } diff --git a/tests/Transport/ProtocolTest.php b/tests/Transport/ProtocolTest.php index 4588a680..c7cc0051 100644 --- a/tests/Transport/ProtocolTest.php +++ b/tests/Transport/ProtocolTest.php @@ -29,9 +29,9 @@ Model\Basic\Message\UserId, Model\Connection\MaxFrameSize, }; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Period, - PointInTime, + Point, Clock, }; use Innmind\IO\IO; @@ -84,7 +84,7 @@ public function testReadHeader() ->withReplyTo(ReplyTo::of('reply')) ->withExpiration(Period::second(1)) ->withId(Id::of('id')) - ->withTimestamp($now = PointInTime::now()) + ->withTimestamp($now = Point::now()) ->withType(Type::of('type')) ->withUserId(UserId::of('guest')) ->withAppId(AppId::of('webcrawler')), @@ -123,7 +123,7 @@ public function testReadHeader() ); $this->assertInstanceOf(Sequence::class, $values); - $this->assertCount(15, $values); // body size + flag bits + 13 properties + $this->assertSame(15, $values->size()); // body size + flag bits + 13 properties $this->assertSame( Str::of('') ->join( From 2375fc5fc4fa5ec3379d113da98486c8593aec07 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 22 Feb 2026 15:24:53 +0100 Subject: [PATCH 2/4] better handle errors when installing signals listener --- src/Client.php | 4 +- src/Transport/Connection.php | 7 ++- src/Transport/Connection/SignalListener.php | 54 ++++++++++++++++----- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/Client.php b/src/Client.php index 8266a894..8510d173 100644 --- a/src/Client.php +++ b/src/Client.php @@ -124,12 +124,12 @@ private function openChannel(): Attempt static fn($protocol) => $protocol->channel()->open($channel), Method::channelOpenOk, ) - ->map(fn() => $this->signals->match( + ->flatMap(fn() => $this->signals->match( static fn($process) => $connection->listenSignals( $process->signals(), $channel, ), - static fn() => null, + static fn() => Attempt::result(SideEffect::identity), )) ->map(static fn() => [$connection, $channel]) ->mapError(Failure::as(Failure::toOpenChannel())), diff --git a/src/Transport/Connection.php b/src/Transport/Connection.php index 0f7244a5..c6ebb749 100644 --- a/src/Transport/Connection.php +++ b/src/Transport/Connection.php @@ -211,9 +211,12 @@ public function tune( )); } - public function listenSignals(Signals $signals, Channel $channel): void + /** + * @return Attempt + */ + public function listenSignals(Signals $signals, Channel $channel): Attempt { - $this->signals->install($signals, $channel); + return $this->signals->install($signals, $channel); } private function flagActive(ReceivedFrame $received): ReceivedFrame diff --git a/src/Transport/Connection/SignalListener.php b/src/Transport/Connection/SignalListener.php index 598c34d1..8fd8ba18 100644 --- a/src/Transport/Connection/SignalListener.php +++ b/src/Transport/Connection/SignalListener.php @@ -15,6 +15,7 @@ use Innmind\Immutable\{ Attempt, Maybe, + SideEffect, }; /** @@ -60,22 +61,51 @@ public static function uninstalled(): self return new self; } - public function install(Signals $signals, Channel $channel): void + /** + * @return Attempt + */ + public function install(Signals $signals, Channel $channel): Attempt { + $installed = Attempt::result(SideEffect::identity); + if (!$this->installed) { - $signals->listen(Signal::hangup, static function() { - // do nothing so it can run in background - }); - $signals->listen(Signal::interrupt, $this->softClose); - $signals->listen(Signal::abort, $this->softClose); - $signals->listen(Signal::terminate, $this->softClose); - $signals->listen(Signal::terminalStop, $this->softClose); - $signals->listen(Signal::alarm, $this->softClose); - $this->signals = Maybe::just($signals); - $this->installed = true; + $installed = $signals + ->listen(Signal::hangup, static function() { + // do nothing so it can run in background + }) + ->flatMap(fn() => $signals->listen( + Signal::interrupt, + $this->softClose, + )) + ->flatMap(fn() => $signals->listen( + Signal::abort, + $this->softClose, + )) + ->flatMap(fn() => $signals->listen( + Signal::terminate, + $this->softClose, + )) + ->flatMap(fn() => $signals->listen( + Signal::terminalStop, + $this->softClose, + )) + ->flatMap(fn() => $signals->listen( + Signal::alarm, + $this->softClose, + )) + ->map(function($_) use ($signals) { + $this->signals = Maybe::just($signals); + $this->installed = true; + + return $_; + }); } - $this->channel = Maybe::just($channel); + return $installed->map(function($_) use ($channel) { + $this->channel = Maybe::just($channel); + + return $_; + }); } public function uninstall(): void From 0499e0a11f3b51b22799f5153fce57bbbb3b75b5 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 22 Feb 2026 15:25:56 +0100 Subject: [PATCH 3/4] fix ci matrix --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9da1a231..ef5f432f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php-version: ['8.2', '8.3', '8.4'] + php-version: ['8.4', '8.5'] dependencies: ['lowest', 'highest'] name: 'BlackBox (${{ matrix.os }}, ${{ matrix.php-version }}, ${{ matrix.dependencies }})' steps: @@ -35,7 +35,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php-version: ['8.2', '8.3', '8.4'] + php-version: ['8.4', '8.5'] dependencies: ['lowest', 'highest'] name: 'Coverage (${{ matrix.os }}, ${{ matrix.php-version }}, ${{ matrix.dependencies }})' steps: @@ -66,5 +66,3 @@ jobs: uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: uses: innmind/github-workflows/.github/workflows/cs.yml@main - with: - php-version: '8.2' From 6b0587f2568f5b3d33ab7ac6dcb98a31d82c51ee Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 22 Feb 2026 15:28:06 +0100 Subject: [PATCH 4/4] fix documentation --- README.md | 2 +- docs/Listen to signals.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f91d946..d982e0cb 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ use Innmind\AMQP\{ Model\Exchange\Type, }; use Innmind\IO\Sockets\Internet\Transport; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\OperatingSystem\Factory as OSFactory; use Innmind\Url\Url; use Innmind\Immutable\Str; diff --git a/docs/Listen to signals.md b/docs/Listen to signals.md index 2c720d59..9aa88e34 100644 --- a/docs/Listen to signals.md +++ b/docs/Listen to signals.md @@ -14,7 +14,7 @@ $client ->run(null) ->match( static fn() => null, // not reachable in this case - static fn($failure) => throw new \RuntimeException($failure::class), + static fn($failure) => $failure, ); ```