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
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
},
"require-dev": {
"phpunit/phpunit": "~10.2",
"vimeo/psalm": "~5.15",
"nikic/php-parser": "^4.15.2",
"innmind/static-analysis": "^1.2.1",
"innmind/black-box": "~5.5",
"innmind/coding-standard": "~2.0"
}
Expand Down
3 changes: 3 additions & 0 deletions src/Client/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(Connection $connection, Protocol $protocol)
$this->protocol = $protocol;
}

#[\Override]
public function send(Message $message): Maybe
{
if ($this->connection->closed()) {
Expand All @@ -37,6 +38,7 @@ public function send(Message $message): Maybe
->map(fn() => $this);
}

#[\Override]
public function read(): Maybe
{
/** @var Maybe<array{Client, Message}> */
Expand All @@ -46,6 +48,7 @@ public function read(): Maybe
->map(fn($message) => [$this, $message]);
}

#[\Override]
public function close(): Maybe
{
return $this->connection->close()->maybe();
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace Innmind\IPC\Exception;

class DomainException extends \DomainException implements Exception
final class DomainException extends \DomainException implements Exception
{
}
5 changes: 5 additions & 0 deletions src/IPC/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function __construct(
$this->heartbeat = $heartbeat;
}

#[\Override]
public function processes(): Set
{
return $this
Expand All @@ -77,6 +78,7 @@ public function processes(): Set
->toSet();
}

#[\Override]
public function get(Process\Name $name): Maybe
{
if (!$this->exist($name)) {
Expand All @@ -94,11 +96,13 @@ public function get(Process\Name $name): Maybe
);
}

#[\Override]
public function exist(Process\Name $name): bool
{
return $this->filesystem->contains(FileName::of("{$name->toString()}.sock"));
}

#[\Override]
public function wait(Process\Name $name, ?ElapsedPeriod $timeout = null): Maybe
{
$start = $this->clock->now();
Expand All @@ -118,6 +122,7 @@ public function wait(Process\Name $name, ?ElapsedPeriod $timeout = null): Maybe
return $this->get($name);
}

#[\Override]
public function listen(Process\Name $self, ?ElapsedPeriod $timeout = null): Server
{
return new Server\Unix(
Expand Down
3 changes: 3 additions & 0 deletions src/Message/ConnectionClose.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ public function __construct()
$this->content = Str::of('innmind/ipc:connection.close');
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
3 changes: 3 additions & 0 deletions src/Message/ConnectionCloseOk.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ public function __construct()
$this->content = Str::of('innmind/ipc:connection.close-ok');
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
3 changes: 3 additions & 0 deletions src/Message/ConnectionStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ public function __construct()
$this->content = Str::of('innmind/ipc:connection.start');
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
3 changes: 3 additions & 0 deletions src/Message/ConnectionStartOk.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ public function __construct()
$this->content = Str::of('innmind/ipc:connection.start-ok');
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
3 changes: 3 additions & 0 deletions src/Message/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ public static function of(string $mediaType, string $content): self
);
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
3 changes: 3 additions & 0 deletions src/Message/Heartbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ public function __construct()
$this->content = Str::of('innmind/ipc:heartbeat');
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
3 changes: 3 additions & 0 deletions src/Message/MessageReceived.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ public function __construct()
$this->content = Str::of('innmind/ipc:message.received');
}

#[\Override]
public function mediaType(): MediaType
{
return $this->mediaType;
}

#[\Override]
public function content(): Str
{
return $this->content;
}

#[\Override]
public function equals(Message $message): bool
{
return $this->mediaType->toString() === $message->mediaType()->toString() &&
Expand Down
5 changes: 5 additions & 0 deletions src/Process/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ public static function of(
->flatMap(static fn($self) => $self->open());
}

#[\Override]
public function name(): Name
{
return $this->name;
}

#[\Override]
public function send(Sequence $messages): Maybe
{
/** @var Maybe<Process> */
Expand All @@ -101,6 +103,7 @@ public function send(Sequence $messages): Maybe
);
}

#[\Override]
public function wait(?ElapsedPeriod $timeout = null): Maybe
{
do {
Expand Down Expand Up @@ -160,6 +163,7 @@ public function wait(?ElapsedPeriod $timeout = null): Maybe
});
}

#[\Override]
public function close(): Maybe
{
if ($this->closed()) {
Expand All @@ -182,6 +186,7 @@ public function close(): Maybe
);
}

#[\Override]
public function closed(): bool
{
return $this->closed || $this->socket->closed();
Expand Down
13 changes: 11 additions & 2 deletions src/Protocol/Binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

final class Binary implements Protocol
{
#[\Override]
public function encode(Message $message): Str
{
$content = $message->content()->toEncoding(Str\Encoding::ascii);
Expand All @@ -35,14 +36,18 @@ public function encode(Message $message): Str
);
}

#[\Override]
public function decode(Readable $stream): Maybe
{
/** @var Maybe<Message> */
return $stream
->read(2)
->filter(static fn($length) => !$length->empty())
->map(static function($length): int {
/** @var positive-int $mediaTypeLength */
/**
* @psalm-suppress PossiblyInvalidArrayAccess Todo apply a predicate
* @var positive-int $mediaTypeLength
*/
[, $mediaTypeLength] = \unpack('n', $length->toString());

return $mediaTypeLength;
Expand All @@ -53,7 +58,10 @@ public function decode(Readable $stream): Maybe
return $stream
->read(4)
->map(static function($length): int {
/** @var positive-int $contentLength */
/**
* @psalm-suppress PossiblyInvalidArrayAccess Todo apply a predicate
* @var positive-int $contentLength
*/
[, $contentLength] = \unpack('N', $length->toString());

return $contentLength;
Expand All @@ -67,6 +75,7 @@ public function decode(Readable $stream): Maybe
fn($parsed) => $stream
->read(1)
->map(static function($end): mixed {
/** @psalm-suppress PossiblyInvalidArrayAccess Todo apply a predicate */
[, $end] = \unpack('C', $end->toString());

return $end;
Expand Down
1 change: 1 addition & 0 deletions src/Server/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function __construct(
*
* @return Either<UnableToStart, C>
*/
#[\Override]
public function __invoke(mixed $carry, callable $listen): Either
{
$iteration = $this
Expand Down
Loading