Skip to content

Update dependencies #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2025
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@

## [Unreleased]

### Changed

- Requires `innmind/time-continuum:^4.1.1`
- Requires `innmind/server-status:~5.0`
- Requires `innmind/server-control:~6.0`
- Requires `innmind/filesystem:~8.1`
- Requires `innmind/file-watch:~5.0`
- Requires `innmind/http-transport:~8.0`
- Requires `innmind/time-warp:~4.0`
- Requires `innmind/io:~3.2`
- Requires `innmind/immutable:~5.15`
- `Innmind\OperatingSystem\Config::withHttpHeartbeat()` period is now expressed with a `Innmind\TimeContinuum\Period`

### Fixed

- PHP `8.4` deprecations

### Removed

- `Innmind\OperatingSystem\Config::useStreamCapabilities()`
- `Innmind\OperatingSystem\Sockets::watch()`

## 5.2.0 - 2024-07-14

### Changed
Expand Down
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
},
"require": {
"php": "~8.2",
"innmind/time-continuum": "~3.0",
"innmind/server-status": "~4.0",
"innmind/server-control": "~5.0",
"innmind/filesystem": "~7.1",
"innmind/socket": "~6.0",
"innmind/http-transport": "~7.2",
"innmind/time-warp": "~3.0",
"innmind/time-continuum": "^4.1.1",
"innmind/server-status": "~5.0",
"innmind/server-control": "~6.0",
"innmind/filesystem": "~8.1",
"innmind/http-transport": "~8.0",
"innmind/time-warp": "~4.0",
"innmind/signals": "~3.0",
"innmind/file-watch": "~4.0",
"innmind/stream": "~4.0",
"innmind/file-watch": "~5.0",
"formal/access-layer": "~4.0",
"innmind/io": "~2.7"
"innmind/io": "~3.2",
"innmind/immutable": "~5.15"
},
"autoload": {
"psr-4": {
Expand All @@ -44,7 +43,7 @@
"innmind/url": "~4.0",
"innmind/ip": "~3.0",
"innmind/static-analysis": "^1.2.1",
"innmind/black-box": "~5.5",
"innmind/black-box": "~6.2",
"innmind/coding-standard": "~2.0"
}
}
67 changes: 9 additions & 58 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,34 @@

use Innmind\TimeContinuum\{
Clock,
Earth,
ElapsedPeriod,
Period,
};
use Innmind\Filesystem\CaseSensitivity;
use Innmind\Server\Status\EnvironmentPath;
use Innmind\TimeWarp\Halt;
use Innmind\IO\IO;
use Innmind\Stream\{
Capabilities,
Streams,
};
use Innmind\Immutable\Maybe;

final class Config
{
private Clock $clock;
private CaseSensitivity $caseSensitivity;
private Capabilities $streamCapabilities;
private IO $io;
private Halt $halt;
private EnvironmentPath $path;
/** @var Maybe<positive-int> */
private Maybe $maxHttpConcurrency;
/** @var Maybe<array{ElapsedPeriod, callable(): void}> */
/** @var Maybe<array{Period, callable(): void}> */
private Maybe $httpHeartbeat;
private bool $disableSSLVerification;

/**
* @param Maybe<positive-int> $maxHttpConcurrency
* @param Maybe<array{ElapsedPeriod, callable(): void}> $httpHeartbeat
* @param Maybe<array{Period, callable(): void}> $httpHeartbeat
*/
private function __construct(
Clock $clock,
CaseSensitivity $caseSensitivity,
Capabilities $streamCapabilities,
IO $io,
Halt $halt,
EnvironmentPath $path,
Expand All @@ -49,7 +42,6 @@ private function __construct(
) {
$this->clock = $clock;
$this->caseSensitivity = $caseSensitivity;
$this->streamCapabilities = $streamCapabilities;
$this->io = $io;
$this->halt = $halt;
$this->path = $path;
Expand All @@ -62,18 +54,14 @@ public static function of(): self
{
/** @var Maybe<positive-int> */
$maxHttpConcurrency = Maybe::nothing();
/** @var Maybe<array{ElapsedPeriod, callable(): void}> */
/** @var Maybe<array{Period, callable(): void}> */
$httpHeartbeat = Maybe::nothing();

return new self(
new Earth\Clock,
Clock::live(),
CaseSensitivity::sensitive,
$streams = Streams::fromAmbientAuthority(),
IO::of(static fn(?ElapsedPeriod $timeout) => match ($timeout) {
null => $streams->watch()->waitForever(),
default => $streams->watch()->timeoutAfter($timeout),
}),
new Halt\Usleep,
IO::fromAmbientAuthority(),
Halt\Usleep::new(),
EnvironmentPath::of(match ($path = \getenv('PATH')) {
false => '',
default => $path,
Expand All @@ -92,7 +80,6 @@ public function withClock(Clock $clock): self
return new self(
$clock,
$this->caseSensitivity,
$this->streamCapabilities,
$this->io,
$this->halt,
$this->path,
Expand All @@ -110,7 +97,6 @@ public function caseInsensitiveFilesystem(): self
return new self(
$this->clock,
CaseSensitivity::insensitive,
$this->streamCapabilities,
$this->io,
$this->halt,
$this->path,
Expand All @@ -120,28 +106,6 @@ public function caseInsensitiveFilesystem(): self
);
}

/**
* @psalm-mutation-free
*/
public function useStreamCapabilities(Capabilities $capabilities): self
{
/** @psalm-suppress ImpureMethodCall This should be solved in the next innmind/io release */
return new self(
$this->clock,
$this->caseSensitivity,
$capabilities,
IO::of(static fn(?ElapsedPeriod $timeout) => match ($timeout) {
null => $capabilities->watch()->waitForever(),
default => $capabilities->watch()->timeoutAfter($timeout),
}),
$this->halt,
$this->path,
$this->maxHttpConcurrency,
$this->httpHeartbeat,
$this->disableSSLVerification,
);
}

/**
* @psalm-mutation-free
*/
Expand All @@ -150,7 +114,6 @@ public function haltProcessVia(Halt $halt): self
return new self(
$this->clock,
$this->caseSensitivity,
$this->streamCapabilities,
$this->io,
$halt,
$this->path,
Expand All @@ -168,7 +131,6 @@ public function withEnvironmentPath(EnvironmentPath $path): self
return new self(
$this->clock,
$this->caseSensitivity,
$this->streamCapabilities,
$this->io,
$this->halt,
$path,
Expand All @@ -188,7 +150,6 @@ public function limitHttpConcurrencyTo(int $max): self
return new self(
$this->clock,
$this->caseSensitivity,
$this->streamCapabilities,
$this->io,
$this->halt,
$this->path,
Expand All @@ -203,12 +164,11 @@ public function limitHttpConcurrencyTo(int $max): self
*
* @param callable(): void $heartbeat
*/
public function withHttpHeartbeat(ElapsedPeriod $timeout, callable $heartbeat): self
public function withHttpHeartbeat(Period $timeout, callable $heartbeat): self
{
return new self(
$this->clock,
$this->caseSensitivity,
$this->streamCapabilities,
$this->io,
$this->halt,
$this->path,
Expand All @@ -226,7 +186,6 @@ public function disableSSLVerification(): self
return new self(
$this->clock,
$this->caseSensitivity,
$this->streamCapabilities,
$this->io,
$this->halt,
$this->path,
Expand All @@ -252,14 +211,6 @@ public function filesystemCaseSensitivity(): CaseSensitivity
return $this->caseSensitivity;
}

/**
* @internal
*/
public function streamCapabilities(): Capabilities
{
return $this->streamCapabilities;
}

/**
* @internal
*/
Expand Down Expand Up @@ -297,7 +248,7 @@ public function maxHttpConcurrency(): Maybe
/**
* @internal
*
* @return Maybe<array{ElapsedPeriod, callable(): void}>
* @return Maybe<array{Period, callable(): void}>
*/
public function httpHeartbeat(): Maybe
{
Expand Down
3 changes: 2 additions & 1 deletion src/CurrentProcess/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function halt(Period $period): void
#[\Override]
public function memory(): Bytes
{
return new Bytes(\memory_get_usage());
/** @psalm-suppress ArgumentTypeCoercion */
return Bytes::of(\memory_get_usage());
}
}
41 changes: 18 additions & 23 deletions src/Filesystem/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
Factory,
Watch,
};
use Innmind\Stream\Bidirectional;
use Innmind\Immutable\{
Maybe,
Attempt,
Sequence,
Str,
Predicate\Instance,
};

final class Generic implements Filesystem
Expand Down Expand Up @@ -64,7 +62,6 @@ public function mount(Path $path): Adapter

$adapter = Adapter\Filesystem::mount(
$path,
$this->config->streamCapabilities(),
$this->config->io(),
)
->withCaseSensitivity(
Expand Down Expand Up @@ -116,24 +113,22 @@ public function watch(Path $path): Ping
#[\Override]
public function temporary(Sequence $chunks): Maybe
{
$temporary = $this
->config
->streamCapabilities()
->temporary()
->new();

$temporary = $chunks->reduce(
Maybe::just($temporary),
static fn(Maybe $temporary, $chunk) => Maybe::all($temporary, $chunk)->flatMap(
static fn(Bidirectional $temporary, Str $chunk) => $temporary
->write($chunk->toEncoding(Str\Encoding::ascii))
->maybe()
->keep(Instance::of(Bidirectional::class)),
),
);

return $temporary
->map($this->config->io()->readable()->wrap(...))
->map(Content::io(...));
return Attempt::of(
fn() => $this
->config
->io()
->files()
->temporary(
$chunks->map(
static fn($chunk) => $chunk
->attempt(static fn() => new \RuntimeException('Failed to load chunk'))
->unwrap(),
),
)
->memoize() // to make sure writing the chunks has been done
->map(static fn($tmp) => $tmp->read())
->map(Content::io(...))
->unwrap(),
)->maybe();
}
}
7 changes: 2 additions & 5 deletions src/Filesystem/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ public function require(Path $path): Maybe
#[\Override]
public function watch(Path $path): Ping
{
return Ping\Logger::psr(
$this->filesystem->watch($path),
$path,
$this->logger,
);
// todo bring back the ping logger
return $this->filesystem->watch($path);
}

#[\Override]
Expand Down
4 changes: 2 additions & 2 deletions src/OperatingSystem/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function map(callable $map): OperatingSystem
#[\Override]
public function clock(): TimeContinuum\Clock
{
return new TimeContinuum\Logger\Clock(
return TimeContinuum\Clock::logger(
$this->os->clock(),
$this->logger,
);
Expand All @@ -62,7 +62,7 @@ public function filesystem(): Filesystem
#[\Override]
public function status(): Status\Server
{
return new Status\Servers\Logger(
return Status\Servers\Logger::of(
$this->os->status(),
$this->logger,
);
Expand Down
2 changes: 1 addition & 1 deletion src/OperatingSystem/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function control(): ServerControl
{
return $this->control ??= Servers\Unix::of(
$this->clock(),
$this->config->streamCapabilities(),
$this->config->io(),
$this->config->halt(),
);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Ports.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
namespace Innmind\OperatingSystem;

use Innmind\Url\Authority\Port;
use Innmind\IO\Sockets\Server;
use Innmind\Socket\Internet\Transport;
use Innmind\IO\{
Sockets\Servers\Server,
Sockets\Internet\Transport,
};
use Innmind\IP\IP;
use Innmind\Immutable\Maybe;

Expand Down
2 changes: 1 addition & 1 deletion src/Ports/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Innmind\OperatingSystem\Ports;
use Innmind\Url\Authority\Port;
use Innmind\Socket\Internet\Transport;
use Innmind\IO\Sockets\Internet\Transport;
use Innmind\IP\IP;
use Innmind\Immutable\Maybe;
use Psr\Log\LoggerInterface;
Expand Down
Loading