From fb877bb87ef0e3c872c670169d971e0b6b908c92 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 18 Nov 2025 11:44:22 +0100 Subject: [PATCH 01/10] require php 8.4 --- .github/workflows/ci.yml | 10 ++++------ CHANGELOG.md | 6 ++++++ composer.json | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 189105d..779f162 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,13 +4,11 @@ on: [push, pull_request] jobs: blackbox: - uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main + uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@next coverage: - uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main + uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@next secrets: inherit psalm: - uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main + uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@next cs: - uses: innmind/github-workflows/.github/workflows/cs.yml@main - with: - php-version: '8.2' + uses: innmind/github-workflows/.github/workflows/cs.yml@next diff --git a/CHANGELOG.md b/CHANGELOG.md index a99eec0..eeb320b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires PHP `8.4` + ## 6.2.0 - 2025-08-10 ### Added diff --git a/composer.json b/composer.json index 67b02d7..fc2763a 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "issues": "http://github.com/Innmind/OperatingSystem/issues" }, "require": { - "php": "~8.2", + "php": "~8.4", "innmind/time-continuum": "^4.1.1", "innmind/server-status": "~5.0", "innmind/server-control": "~6.0", From abb7666a8c56aba641acce76928a34338759b47e Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 18 Nov 2025 11:57:22 +0100 Subject: [PATCH 02/10] add todo for Filesystem::contains() to integrate correctly with other abstractions --- src/Filesystem.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Filesystem.php b/src/Filesystem.php index 4454165..a74f9be 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -76,6 +76,7 @@ public function mount(Path $path): Attempt #[\NoDiscard] public function contains(Path $path): bool { + // todo find a way to not directly access the filesystem if (!\file_exists($path->toString())) { return false; } From 596fe41d4e33b03e1cd3da2be9e8c809b97c6224 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 18 Nov 2025 12:22:17 +0100 Subject: [PATCH 03/10] update dependencies --- composer.json | 29 +++++++------ src/Config.php | 24 ++++------- src/Config/Logger.php | 14 +++---- src/Config/Resilient.php | 4 +- src/OperatingSystem.php | 7 +--- src/Remote.php | 7 +--- tests/CurrentProcessTest.php | 6 +-- tests/FactoryTest.php | 12 +++--- tests/FilesystemTest.php | 4 +- tests/Remote/ResilientTest.php | 4 +- tests/RemoteTest.php | 77 +++++++--------------------------- 11 files changed, 64 insertions(+), 124 deletions(-) diff --git a/composer.json b/composer.json index fc2763a..6b185e3 100644 --- a/composer.json +++ b/composer.json @@ -16,17 +16,22 @@ }, "require": { "php": "~8.4", - "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": "~4.0", - "innmind/file-watch": "~5.0", - "formal/access-layer": "~4.0", - "innmind/io": "~3.2", - "innmind/immutable": "~5.15" + "innmind/time-continuum": "dev-next", + "innmind/server-status": "dev-next", + "innmind/server-control": "dev-next", + "innmind/filesystem": "dev-next", + "innmind/http-transport": "dev-next", + "innmind/time-warp": "dev-next", + "innmind/signals": "dev-next", + "innmind/file-watch": "dev-next", + "formal/access-layer": "dev-next", + "innmind/io": "dev-next", + "innmind/immutable": "dev-next", + "innmind/http": "dev-next", + "innmind/media-type": "dev-next", + "innmind/url": "dev-next", + "innmind/validation": "dev-next", + "innmind/ip": "dev-next" }, "autoload": { "psr-4": { @@ -39,8 +44,6 @@ } }, "require-dev": { - "innmind/url": "~4.0", - "innmind/ip": "~3.0", "innmind/static-analysis": "^1.2.1", "innmind/black-box": "~6.2", "innmind/coding-standard": "~2.0" diff --git a/src/Config.php b/src/Config.php index e866fc8..e960587 100644 --- a/src/Config.php +++ b/src/Config.php @@ -6,13 +6,10 @@ use Innmind\Server\Control; use Innmind\Server\Status; use Innmind\TimeContinuum\Clock; -use Innmind\HttpTransport\{ - Transport as HttpTransport, - Curl, -}; +use Innmind\HttpTransport\Transport as HttpTransport; use Innmind\Filesystem\{ Adapter as Filesystem, - CaseSensitivity + CaseSensitivity, }; use Innmind\FileWatch\Watch; use Innmind\Server\Status\EnvironmentPath; @@ -69,7 +66,7 @@ public static function new(): self Clock::live(), static fn(Clock $clock) => $clock, IO::fromAmbientAuthority(), - Halt\Usleep::new(), + Halt::new(), static fn(Halt $halt, self $config) => $halt, EnvironmentPath::of(match ($path = \getenv('PATH')) { false => '', @@ -77,18 +74,15 @@ public static function new(): self }), null, static fn(HttpTransport $transport, self $config) => $transport, - static fn(Url $server) => AccessLayer\Connection\Lazy::of( - static fn() => AccessLayer\Connection\PDO::of($server), - ), + static fn(Url $server) => AccessLayer\Connection::new($server)->unwrap(), static fn(AccessLayer\Connection $connection, self $config) => $connection, static fn(Control\Server $server, self $config) => $server, static fn(Status\Server $server, self $config) => $server, static fn(Watch $watch, self $config) => $watch, - static fn(Path $path, self $config) => Attempt::of( - static fn() => Filesystem\Filesystem::mount( - $path, - $config->io(), - )->withCaseSensitivity(CaseSensitivity::sensitive), + static fn(Path $path, self $config) => Filesystem::mount( + $path, + CaseSensitivity::sensitive, + $config->io(), ), static fn(Filesystem $filesystem, self $config) => $filesystem, Handler::main(), @@ -639,7 +633,7 @@ public function environmentPath(): EnvironmentPath #[\NoDiscard] public function httpTransport(): HttpTransport { - $transport = $this->httpTransport ?? Curl::of( + $transport = $this->httpTransport ?? HttpTransport::curl( $this->clock, $this->io, ); diff --git a/src/Config/Logger.php b/src/Config/Logger.php index fb7d2a4..f7d388f 100644 --- a/src/Config/Logger.php +++ b/src/Config/Logger.php @@ -9,7 +9,7 @@ use Innmind\TimeContinuum\Clock; use Innmind\FileWatch\Watch; use Innmind\Filesystem\Adapter as Filesystem; -use Innmind\HttpTransport; +use Innmind\HttpTransport\Transport; use Innmind\TimeWarp\Halt; use Formal\AccessLayer\Connection; use Psr\Log\LoggerInterface; @@ -28,23 +28,23 @@ private function __construct( public function __invoke(Config $config): Config { return $config - ->mapHalt(fn($halt) => Halt\Logger::psr( + ->mapHalt(fn($halt) => Halt::logger( $halt, $this->logger, )) - ->mapHttpTransport(fn($transport) => HttpTransport\Logger::psr( + ->mapHttpTransport(fn($transport) => Transport::logger( $transport, $this->logger, )) - ->mapSQLConnection(fn($connection) => Connection\Logger::psr( + ->mapSQLConnection(fn($connection) => Connection::logger( $connection, $this->logger, )) - ->mapServerControl(fn($server) => Control\Servers\Logger::psr( + ->mapServerControl(fn($server) => Control\Server::logger( $server, $this->logger, )) - ->mapServerStatus(fn($server) => Status\Servers\Logger::of( + ->mapServerStatus(fn($server) => Status\Server::logger( $server, $this->logger, )) @@ -53,7 +53,7 @@ public function __invoke(Config $config): Config $watch, $this->logger, )) - ->mapFilesystem(fn($filesystem) => Filesystem\Logger::psr( + ->mapFilesystem(fn($filesystem) => Filesystem::logger( $filesystem, $this->logger, )); diff --git a/src/Config/Resilient.php b/src/Config/Resilient.php index 3f44206..7d2f83d 100644 --- a/src/Config/Resilient.php +++ b/src/Config/Resilient.php @@ -4,7 +4,7 @@ namespace Innmind\OperatingSystem\Config; use Innmind\OperatingSystem\Config; -use Innmind\HttpTransport\ExponentialBackoff; +use Innmind\HttpTransport\Transport; /** * @psalm-immutable @@ -17,7 +17,7 @@ enum Resilient public function __invoke(Config $config): Config { return $config - ->mapHttpTransport(static fn($transport, $config) => ExponentialBackoff::of( + ->mapHttpTransport(static fn($transport, $config) => Transport::exponentialBackoff( $transport, $config->halt(), )); diff --git a/src/OperatingSystem.php b/src/OperatingSystem.php index e99877c..b3d515c 100644 --- a/src/OperatingSystem.php +++ b/src/OperatingSystem.php @@ -7,10 +7,7 @@ Server as ServerStatus, ServerFactory, }; -use Innmind\Server\Control\{ - Server as ServerControl, - Servers, -}; +use Innmind\Server\Control\Server as ServerControl; use Innmind\TimeContinuum\Clock; final class OperatingSystem @@ -78,7 +75,7 @@ public function status(): ServerStatus public function control(): ServerControl { return $this->control ??= $this->config->serverControl( - Servers\Unix::of( + ServerControl::new( $this->clock(), $this->config->io(), $this->config->halt(), diff --git a/src/Remote.php b/src/Remote.php index fee3f57..a50355b 100644 --- a/src/Remote.php +++ b/src/Remote.php @@ -3,10 +3,7 @@ namespace Innmind\OperatingSystem; -use Innmind\Server\Control\{ - Server, - Servers, -}; +use Innmind\Server\Control\Server; use Innmind\IO\{ Sockets\Clients\Client, Sockets\Internet\Transport, @@ -51,7 +48,7 @@ public function ssh(Url $server): Server } return $this->config->serverControl( - Servers\Remote::of( + Server::remote( $this->server, $server->authority()->userInformation()->user(), $server->authority()->host(), diff --git a/tests/CurrentProcessTest.php b/tests/CurrentProcessTest.php index ca7b1a3..ba3eef6 100644 --- a/tests/CurrentProcessTest.php +++ b/tests/CurrentProcessTest.php @@ -33,7 +33,7 @@ class CurrentProcessTest extends TestCase public function testId() { $process = CurrentProcess::of( - Halt\Usleep::new(), + Halt::new(), Handler::main(), ); @@ -66,7 +66,7 @@ public function testHalt(): BlackBox\Proof public function testSignals() { $process = CurrentProcess::of( - Halt\Usleep::new(), + Halt::new(), Handler::main(), ); @@ -101,7 +101,7 @@ public function testAsyncSignals(): BlackBox\Proof public function testMemory() { $process = CurrentProcess::of( - Halt\Usleep::new(), + Halt::new(), Handler::main(), ); diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index 1df7a75..3b4fdd6 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -10,14 +10,13 @@ }; use Innmind\TimeContinuum\Clock; use Innmind\Filesystem\{ - Adapter\Filesystem, + Adapter, File, File\Content, Directory, CaseSensitivity, }; use Innmind\Url\Path; -use Innmind\Immutable\Attempt; use Symfony\Component\Filesystem\Filesystem as FS; use Innmind\BlackBox\PHPUnit\Framework\TestCase; @@ -53,11 +52,10 @@ public function testPersistingFileOnCaseInsensitiveFilesystem() $os = Factory::build( Config::new()->mountFilesystemVia( - static fn($path, $config) => Attempt::of( - static fn() => Filesystem::mount( - $path, - $config->io(), - )->withCaseSensitivity(CaseSensitivity::insensitive), + static fn($path, $config) => Adapter::mount( + $path, + CaseSensitivity::insensitive, + $config->io(), ), ), ); diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index b852d3c..1a2ba90 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -9,7 +9,7 @@ Factory, }; use Innmind\Filesystem\{ - Adapter\Filesystem as FilesystemAdapter, + Adapter, File\Content, }; use Innmind\Url\Path; @@ -40,7 +40,7 @@ public function testMount() $adapter = $filesystem->mount(Path::of('/tmp/'))->unwrap(); - $this->assertInstanceOf(FilesystemAdapter::class, $adapter); + $this->assertInstanceOf(Adapter::class, $adapter); } public function testMountingTheSamePathTwiceReturnsTheSameAdapter() diff --git a/tests/Remote/ResilientTest.php b/tests/Remote/ResilientTest.php index 6a9f805..1712794 100644 --- a/tests/Remote/ResilientTest.php +++ b/tests/Remote/ResilientTest.php @@ -7,7 +7,7 @@ Config, Factory, }; -use Innmind\HttpTransport\ExponentialBackoff; +use Innmind\HttpTransport\Transport; use Innmind\BlackBox\PHPUnit\Framework\TestCase; class ResilientTest extends TestCase @@ -25,6 +25,6 @@ public function testHttp() Config\Resilient::new(), ); - $this->assertInstanceOf(ExponentialBackoff::class, $os->remote()->http()); + $this->assertInstanceOf(Transport::class, $os->remote()->http()); } } diff --git a/tests/RemoteTest.php b/tests/RemoteTest.php index c9a5d1d..b44c10e 100644 --- a/tests/RemoteTest.php +++ b/tests/RemoteTest.php @@ -11,12 +11,7 @@ }; use Innmind\Server\Control\{ Server, - Servers, - Server\Processes, - Server\Volumes, Server\Command, - Server\Process\Pid, - Server\Signal, }; use Innmind\Url\{ Url, @@ -28,7 +23,6 @@ }; use Innmind\IP\IPv4; use Innmind\HttpTransport\Transport as HttpTransport; -use Innmind\Immutable\Attempt; use Formal\AccessLayer\Connection; use Innmind\BlackBox\{ PHPUnit\BlackBox, @@ -51,7 +45,7 @@ public function testSsh() $remoteServer = $remote->ssh(Url::of('ssh://user@my-vps:42/')); - $this->assertInstanceOf(Servers\Remote::class, $remoteServer); + $this->assertInstanceOf(Server::class, $remoteServer); $remoteServer ->processes() ->execute(Command::foreground('ls')) @@ -67,7 +61,7 @@ public function testSshLogger() $remoteServer = $remote->ssh(Url::of('ssh://user@my-vps:42/')); - $this->assertInstanceOf(Servers\Logger::class, $remoteServer); + $this->assertInstanceOf(Server::class, $remoteServer); $remoteServer ->processes() ->execute(Command::foreground('ls')) @@ -83,7 +77,7 @@ public function testSshWithoutPort() $remoteServer = $remote->ssh(Url::of('ssh://user@my-vps/')); - $this->assertInstanceOf(Servers\Remote::class, $remoteServer); + $this->assertInstanceOf(Server::class, $remoteServer); $remoteServer->processes()->execute(Command::foreground('ls')); } @@ -146,60 +140,17 @@ public function testSql(): BlackBox\Proof private function server(string ...$commands): Server { - return new class($this->processes(), $this, $commands) implements Server { - private $inner; - - public function __construct( - private $processes, - private $test, - private $commands, - ) { - } - - public function processes(): Processes - { - return $this->inner ??= new class($this->processes, $this->test, $this->commands) implements Processes { - public function __construct( - private $processes, - private $test, - private $commands, - ) { - } - - public function execute(Command $command): Attempt - { - $expected = \array_shift($this->commands); - $this->test->assertNotNull($expected); - $this->test->assertSame( - $expected, - $command->toString(), - ); - - return $this->processes->execute(Command::foreground('echo')); - } - - public function kill(Pid $pid, Signal $signal): Attempt - { - } - }; - } - - public function volumes(): Volumes - { - } - - public function reboot(): Attempt - { - } - - public function shutdown(): Attempt - { - } - }; - } + $processes = Factory::build()->control()->processes(); + + return Server::via(function($command) use (&$commands, $processes) { + $expected = \array_shift($commands); + $this->assertNotNull($expected); + $this->assertSame( + $expected, + $command->toString(), + ); - private function processes(): Processes - { - return Factory::build()->control()->processes(); + return $processes->execute(Command::foreground('echo')); + }); } } From 640df0e8d8422fa0c3d8004ffa5af9a74891e376 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 18 Nov 2025 12:28:15 +0100 Subject: [PATCH 04/10] make Remote::sql() return an Attempt --- CHANGELOG.md | 1 + src/Config.php | 18 +++++++++++------- src/Remote.php | 5 ++++- tests/RemoteTest.php | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb320b..f923708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - Requires PHP `8.4` +- `Innmind\OperatingSystem\Remote::sql()` now returns an `Innmind\Immutable\Attempt` ## 6.2.0 - 2025-08-10 diff --git a/src/Config.php b/src/Config.php index e960587..aa1b959 100644 --- a/src/Config.php +++ b/src/Config.php @@ -31,7 +31,7 @@ final class Config * @param \Closure(Clock, self): Clock $mapClock * @param \Closure(Halt, self): Halt $mapHalt * @param \Closure(HttpTransport, self): HttpTransport $mapHttpTransport - * @param \Closure(Url): AccessLayer\Connection $sql + * @param \Closure(Url): Attempt $sql * @param \Closure(AccessLayer\Connection, self): AccessLayer\Connection $mapSql * @param \Closure(Control\Server, self): Control\Server $mapServerControl * @param \Closure(Status\Server, self): Status\Server $mapServerStatus @@ -74,7 +74,7 @@ public static function new(): self }), null, static fn(HttpTransport $transport, self $config) => $transport, - static fn(Url $server) => AccessLayer\Connection::new($server)->unwrap(), + static fn(Url $server) => AccessLayer\Connection::new($server), static fn(AccessLayer\Connection $connection, self $config) => $connection, static fn(Control\Server $server, self $config) => $server, static fn(Status\Server $server, self $config) => $server, @@ -334,7 +334,7 @@ public function mapHttpTransport(\Closure $map): self /** * @psalm-mutation-free * - * @param \Closure(Url): AccessLayer\Connection $sql + * @param \Closure(Url): Attempt $sql */ #[\NoDiscard] public function openSQLConnectionVia(\Closure $sql): self @@ -643,13 +643,17 @@ public function httpTransport(): HttpTransport /** * @internal + * + * @return Attempt */ #[\NoDiscard] - public function sql(Url $url): AccessLayer\Connection + public function sql(Url $url): Attempt { - return ($this->mapSql)( - ($this->sql)($url), - $this, + $map = $this->mapSql; + $self = $this; + + return ($this->sql)($url)->map( + static fn($connection) => $map($connection, $self), ); } diff --git a/src/Remote.php b/src/Remote.php index a50355b..a549031 100644 --- a/src/Remote.php +++ b/src/Remote.php @@ -77,8 +77,11 @@ public function http(): HttpTransport return $this->http ??= $this->config->httpTransport(); } + /** + * @return Attempt + */ #[\NoDiscard] - public function sql(Url $server): Connection + public function sql(Url $server): Attempt { return $this->config->sql($server); } diff --git a/tests/RemoteTest.php b/tests/RemoteTest.php index b44c10e..cb024c6 100644 --- a/tests/RemoteTest.php +++ b/tests/RemoteTest.php @@ -23,7 +23,7 @@ }; use Innmind\IP\IPv4; use Innmind\HttpTransport\Transport as HttpTransport; -use Formal\AccessLayer\Connection; +use Innmind\Immutable\Attempt; use Innmind\BlackBox\{ PHPUnit\BlackBox, PHPUnit\Framework\TestCase, @@ -134,7 +134,7 @@ public function testSql(): BlackBox\Proof ->prove(function($server, $os) { $sql = $os->remote()->sql($server); - $this->assertInstanceOf(Connection::class, $sql); + $this->assertInstanceOf(Attempt::class, $sql); }); } From 90f3f807b1ddbb90c16c3d20200534c57dde6935 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Wed, 19 Nov 2025 12:32:09 +0100 Subject: [PATCH 05/10] use the filesystem abstraction to check if a file/directory exists --- CHANGELOG.md | 1 + src/Config.php | 17 +++++++++++++++-- src/Filesystem.php | 28 +++++++++++++++++++++------- tests/FactoryTest.php | 2 ++ tests/FilesystemTest.php | 3 +++ 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f923708..d412754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Requires PHP `8.4` - `Innmind\OperatingSystem\Remote::sql()` now returns an `Innmind\Immutable\Attempt` +- `Innmind\OperatingSystem\Filesystem::mount()` now longer automatically create the directory ## 6.2.0 - 2025-08-10 diff --git a/src/Config.php b/src/Config.php index aa1b959..d6a98d5 100644 --- a/src/Config.php +++ b/src/Config.php @@ -10,6 +10,7 @@ use Innmind\Filesystem\{ Adapter as Filesystem, CaseSensitivity, + Exception\RecoverMount, }; use Innmind\FileWatch\Watch; use Innmind\Server\Status\EnvironmentPath; @@ -595,9 +596,21 @@ public function clock(): Clock #[\NoDiscard] public function filesystem(Path $path): Attempt { - return ($this->filesystem)($path, $this)->map( - fn($adapter) => ($this->mapFilesystem)($adapter, $this), + $map = fn(Filesystem $adapter): Filesystem => ($this->mapFilesystem)( + $adapter, + $this, ); + + return ($this->filesystem)($path, $this) + ->mapError(static fn($e) => match (true) { + $e instanceof RecoverMount => new RecoverMount( + static fn() => $e + ->recover() + ->map($map), + ), + default => $e, + }) + ->map($map); } /** diff --git a/src/Filesystem.php b/src/Filesystem.php index a74f9be..7b4b78c 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -6,6 +6,8 @@ use Innmind\Filesystem\{ Adapter, File\Content, + Directory, + Name, }; use Innmind\Url\Path; use Innmind\Server\Control\Server\Processes; @@ -76,16 +78,28 @@ public function mount(Path $path): Attempt #[\NoDiscard] public function contains(Path $path): bool { - // todo find a way to not directly access the filesystem - if (!\file_exists($path->toString())) { - return false; - } + $dir = \rtrim(\dirname($path->toString()), '/').'/'; + $name = \basename($path->toString()); - if ($path->directory() && !\is_dir($path->toString())) { - return false; + $exists = $this + ->config + ->filesystem(Path::of($dir)) + ->maybe(); + + // empty when the path === '/' + if ($name !== '') { + $exists = $exists + ->flatMap(static fn($adapter) => $adapter->get(Name::of($name))) + ->filter(static fn($file) => match (true) { + $path->directory() && !($file instanceof Directory) => false, + default => true, + }); } - return true; + return $exists->match( + static fn() => true, + static fn() => false, + ); } /** diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index 3b4fdd6..bc1cf2b 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -15,6 +15,7 @@ File\Content, Directory, CaseSensitivity, + Recover, }; use Innmind\Url\Path; use Symfony\Component\Filesystem\Filesystem as FS; @@ -62,6 +63,7 @@ public function testPersistingFileOnCaseInsensitiveFilesystem() $adapter = $os ->filesystem() ->mount(Path::of($path)) + ->recover(Recover::mount(...)) ->unwrap(); $adapter->add( $directory = Directory::named('0') diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index 1a2ba90..dad311c 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -79,6 +79,9 @@ public function testContainsDirectory() \mkdir('/tmp/some-dir/'); $this->assertTrue($filesystem->contains(Path::of('/tmp/some-dir/'))); \rmdir('/tmp/some-dir/'); + \file_put_contents('/tmp/foo', 'data'); + $this->assertFalse($filesystem->contains(Path::of('/tmp/foo/'))); + \unlink('/tmp/foo'); } public function testWatch() From b3dfc893a3f74f9d4e8ee8138d39fbae5b959b50 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 25 Nov 2025 13:59:50 +0100 Subject: [PATCH 06/10] add Config::useServerControl() --- CHANGELOG.md | 4 +++ src/Config.php | 56 +++++++++++++++++++++++++++++++++++++++-- src/OperatingSystem.php | 8 +----- src/Remote.php | 12 ++++----- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d412754..7c253a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- `Innmind\OperatingSystem\Config::useServerControl()` + ### Changed - Requires PHP `8.4` diff --git a/src/Config.php b/src/Config.php index d6a98d5..02c1879 100644 --- a/src/Config.php +++ b/src/Config.php @@ -51,6 +51,7 @@ private function __construct( private \Closure $mapHttpTransport, private \Closure $sql, private \Closure $mapSql, + private ?Control\Server $serverControl, private \Closure $mapServerControl, private \Closure $mapServerStatus, private \Closure $mapFileWatch, @@ -77,6 +78,7 @@ public static function new(): self static fn(HttpTransport $transport, self $config) => $transport, static fn(Url $server) => AccessLayer\Connection::new($server), static fn(AccessLayer\Connection $connection, self $config) => $connection, + null, static fn(Control\Server $server, self $config) => $server, static fn(Status\Server $server, self $config) => $server, static fn(Watch $watch, self $config) => $watch, @@ -119,6 +121,7 @@ public function withClock(Clock $clock): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -152,6 +155,7 @@ public function mapClock(\Closure $map): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -178,6 +182,7 @@ public function haltProcessVia(Halt $halt): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -212,6 +217,7 @@ public function mapHalt(\Closure $map): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -238,6 +244,7 @@ public function withIO(IO $io): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -264,6 +271,7 @@ public function withEnvironmentPath(EnvironmentPath $path): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -290,6 +298,7 @@ public function useHttpTransport(HttpTransport $transport): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -323,6 +332,7 @@ public function mapHttpTransport(\Closure $map): self ), $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -351,6 +361,7 @@ public function openSQLConnectionVia(\Closure $sql): self $this->mapHttpTransport, $sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -384,6 +395,34 @@ public function mapSQLConnection(\Closure $map): self $previous($connection, $config), $config, ), + $this->serverControl, + $this->mapServerControl, + $this->mapServerStatus, + $this->mapFileWatch, + $this->filesystem, + $this->mapFilesystem, + $this->signals, + ); + } + + /** + * @psalm-mutation-free + */ + #[\NoDiscard] + public function useServerControl(Control\Server $server): self + { + return new self( + $this->clock, + $this->mapClock, + $this->io, + $this->halt, + $this->mapHalt, + $this->path, + $this->httpTransport, + $this->mapHttpTransport, + $this->sql, + $this->mapSql, + $server, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -414,6 +453,7 @@ public function mapServerControl(\Closure $map): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, static fn(Control\Server $server, self $config) => $map( $previous($server, $config), $config, @@ -447,6 +487,7 @@ public function mapServerStatus(\Closure $map): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, static fn(Status\Server $server, self $config) => $map( $previous($server, $config), @@ -480,6 +521,7 @@ public function mapFileWatch(\Closure $map): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, static fn(Watch $watch, self $config) => $map( @@ -511,6 +553,7 @@ public function mountFilesystemVia(\Closure $filesystem): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -541,6 +584,7 @@ public function mapFilesystem(\Closure $map): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -570,6 +614,7 @@ public function handleSignalsVia(Handler $handler): self $this->mapHttpTransport, $this->sql, $this->mapSql, + $this->serverControl, $this->mapServerControl, $this->mapServerStatus, $this->mapFileWatch, @@ -674,9 +719,16 @@ public function sql(Url $url): Attempt * @internal */ #[\NoDiscard] - public function serverControl(Control\Server $server): Control\Server + public function serverControl(): Control\Server { - return ($this->mapServerControl)($server, $this); + return ($this->mapServerControl)( + $this->serverControl ?? Control\Server::new( + $this->clock, + $this->io, + $this->halt(), + ), + $this, + ); } /** diff --git a/src/OperatingSystem.php b/src/OperatingSystem.php index b3d515c..6388f05 100644 --- a/src/OperatingSystem.php +++ b/src/OperatingSystem.php @@ -74,13 +74,7 @@ public function status(): ServerStatus #[\NoDiscard] public function control(): ServerControl { - return $this->control ??= $this->config->serverControl( - ServerControl::new( - $this->clock(), - $this->config->io(), - $this->config->halt(), - ), - ); + return $this->control ??= $this->config->serverControl(); } #[\NoDiscard] diff --git a/src/Remote.php b/src/Remote.php index a549031..b81a88a 100644 --- a/src/Remote.php +++ b/src/Remote.php @@ -47,13 +47,11 @@ public function ssh(Url $server): Server $port = $server->authority()->port(); } - return $this->config->serverControl( - Server::remote( - $this->server, - $server->authority()->userInformation()->user(), - $server->authority()->host(), - $port, - ), + return Server::remote( + $this->server, + $server->authority()->userInformation()->user(), + $server->authority()->host(), + $port, ); } From 84e2c5046536cc5deac098a0f027862f8bc53295 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 25 Nov 2025 14:07:47 +0100 Subject: [PATCH 07/10] add Config::useServerStatus() --- CHANGELOG.md | 1 + src/Config.php | 67 ++++++++++++++++++++++++++++++++++++++--- src/OperatingSystem.php | 21 +++++-------- 3 files changed, 70 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c253a7..9c1d473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - `Innmind\OperatingSystem\Config::useServerControl()` +- `Innmind\OperatingSystem\Config::useServerStatus()` ### Changed diff --git a/src/Config.php b/src/Config.php index 02c1879..8b14c6e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,8 +3,12 @@ namespace Innmind\OperatingSystem; -use Innmind\Server\Control; -use Innmind\Server\Status; +use Innmind\Server\{ + Control, + Status, + Status\EnvironmentPath, + Status\ServerFactory, +}; use Innmind\TimeContinuum\Clock; use Innmind\HttpTransport\Transport as HttpTransport; use Innmind\Filesystem\{ @@ -13,7 +17,6 @@ Exception\RecoverMount, }; use Innmind\FileWatch\Watch; -use Innmind\Server\Status\EnvironmentPath; use Innmind\Signals\Handler; use Innmind\TimeWarp\Halt; use Innmind\IO\IO; @@ -53,6 +56,7 @@ private function __construct( private \Closure $mapSql, private ?Control\Server $serverControl, private \Closure $mapServerControl, + private ?Status\Server $serverStatus, private \Closure $mapServerStatus, private \Closure $mapFileWatch, private \Closure $filesystem, @@ -80,6 +84,7 @@ public static function new(): self static fn(AccessLayer\Connection $connection, self $config) => $connection, null, static fn(Control\Server $server, self $config) => $server, + null, static fn(Status\Server $server, self $config) => $server, static fn(Watch $watch, self $config) => $watch, static fn(Path $path, self $config) => Filesystem::mount( @@ -123,6 +128,7 @@ public function withClock(Clock $clock): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -157,6 +163,7 @@ public function mapClock(\Closure $map): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -184,6 +191,7 @@ public function haltProcessVia(Halt $halt): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -219,6 +227,7 @@ public function mapHalt(\Closure $map): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -246,6 +255,7 @@ public function withIO(IO $io): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -273,6 +283,7 @@ public function withEnvironmentPath(EnvironmentPath $path): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -300,6 +311,7 @@ public function useHttpTransport(HttpTransport $transport): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -334,6 +346,7 @@ public function mapHttpTransport(\Closure $map): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -363,6 +376,7 @@ public function openSQLConnectionVia(\Closure $sql): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -397,6 +411,7 @@ public function mapSQLConnection(\Closure $map): self ), $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -424,6 +439,7 @@ public function useServerControl(Control\Server $server): self $this->mapSql, $server, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -458,6 +474,35 @@ public function mapServerControl(\Closure $map): self $previous($server, $config), $config, ), + $this->serverStatus, + $this->mapServerStatus, + $this->mapFileWatch, + $this->filesystem, + $this->mapFilesystem, + $this->signals, + ); + } + + /** + * @psalm-mutation-free + */ + #[\NoDiscard] + public function useServerStatus(Status\Server $server): self + { + return new self( + $this->clock, + $this->mapClock, + $this->io, + $this->halt, + $this->mapHalt, + $this->path, + $this->httpTransport, + $this->mapHttpTransport, + $this->sql, + $this->mapSql, + $this->serverControl, + $this->mapServerControl, + $server, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -489,6 +534,7 @@ public function mapServerStatus(\Closure $map): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, static fn(Status\Server $server, self $config) => $map( $previous($server, $config), $config, @@ -523,6 +569,7 @@ public function mapFileWatch(\Closure $map): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, static fn(Watch $watch, self $config) => $map( $previous($watch, $config), @@ -555,6 +602,7 @@ public function mountFilesystemVia(\Closure $filesystem): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $filesystem, @@ -586,6 +634,7 @@ public function mapFilesystem(\Closure $map): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -616,6 +665,7 @@ public function handleSignalsVia(Handler $handler): self $this->mapSql, $this->serverControl, $this->mapServerControl, + $this->serverStatus, $this->mapServerStatus, $this->mapFileWatch, $this->filesystem, @@ -735,9 +785,16 @@ public function serverControl(): Control\Server * @internal */ #[\NoDiscard] - public function serverStatus(Status\Server $server): Status\Server + public function serverStatus(Control\Server $server): Status\Server { - return ($this->mapServerStatus)($server, $this); + return ($this->mapServerStatus)( + $this->serverStatus ?? ServerFactory::build( + $this->clock(), + $server, + $this->path, + ), + $this, + ); } /** diff --git a/src/OperatingSystem.php b/src/OperatingSystem.php index 6388f05..1ce26aa 100644 --- a/src/OperatingSystem.php +++ b/src/OperatingSystem.php @@ -3,19 +3,16 @@ namespace Innmind\OperatingSystem; -use Innmind\Server\Status\{ - Server as ServerStatus, - ServerFactory, -}; -use Innmind\Server\Control\Server as ServerControl; +use Innmind\Server\Status; +use Innmind\Server\Control; use Innmind\TimeContinuum\Clock; final class OperatingSystem { private Config $config; private ?Filesystem $filesystem = null; - private ?ServerStatus $status = null; - private ?ServerControl $control = null; + private ?Status\Server $status = null; + private ?Control\Server $control = null; private ?Ports $ports = null; private ?Sockets $sockets = null; private ?Remote $remote = null; @@ -60,19 +57,15 @@ public function filesystem(): Filesystem } #[\NoDiscard] - public function status(): ServerStatus + public function status(): Status\Server { return $this->status ??= $this->config->serverStatus( - ServerFactory::build( - $this->clock(), - $this->control(), - $this->config->environmentPath(), - ), + $this->control(), ); } #[\NoDiscard] - public function control(): ServerControl + public function control(): Control\Server { return $this->control ??= $this->config->serverControl(); } From 039ba30fd9eaea311e3a746c0f68f3c5334762ed Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 25 Nov 2025 14:13:55 +0100 Subject: [PATCH 08/10] add Config::useFileWatch() --- CHANGELOG.md | 1 + src/Config.php | 56 ++++++++++++++++++++++++++++++++++++++++++++-- src/Filesystem.php | 5 +---- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c1d473..4d2e4ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - `Innmind\OperatingSystem\Config::useServerControl()` - `Innmind\OperatingSystem\Config::useServerStatus()` +- `Innmind\OperatingSystem\Config::useFileWatch()` ### Changed diff --git a/src/Config.php b/src/Config.php index 8b14c6e..7bfa62a 100644 --- a/src/Config.php +++ b/src/Config.php @@ -58,6 +58,7 @@ private function __construct( private \Closure $mapServerControl, private ?Status\Server $serverStatus, private \Closure $mapServerStatus, + private ?Watch $watch, private \Closure $mapFileWatch, private \Closure $filesystem, private \Closure $mapFilesystem, @@ -86,6 +87,7 @@ public static function new(): self static fn(Control\Server $server, self $config) => $server, null, static fn(Status\Server $server, self $config) => $server, + null, static fn(Watch $watch, self $config) => $watch, static fn(Path $path, self $config) => Filesystem::mount( $path, @@ -130,6 +132,7 @@ public function withClock(Clock $clock): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -165,6 +168,7 @@ public function mapClock(\Closure $map): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -193,6 +197,7 @@ public function haltProcessVia(Halt $halt): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -229,6 +234,7 @@ public function mapHalt(\Closure $map): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -257,6 +263,7 @@ public function withIO(IO $io): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -285,6 +292,7 @@ public function withEnvironmentPath(EnvironmentPath $path): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -313,6 +321,7 @@ public function useHttpTransport(HttpTransport $transport): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -348,6 +357,7 @@ public function mapHttpTransport(\Closure $map): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -378,6 +388,7 @@ public function openSQLConnectionVia(\Closure $sql): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -413,6 +424,7 @@ public function mapSQLConnection(\Closure $map): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -441,6 +453,7 @@ public function useServerControl(Control\Server $server): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -476,6 +489,7 @@ public function mapServerControl(\Closure $map): self ), $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -504,6 +518,7 @@ public function useServerStatus(Status\Server $server): self $this->mapServerControl, $server, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -539,6 +554,36 @@ public function mapServerStatus(\Closure $map): self $previous($server, $config), $config, ), + $this->watch, + $this->mapFileWatch, + $this->filesystem, + $this->mapFilesystem, + $this->signals, + ); + } + + /** + * @psalm-mutation-free + */ + #[\NoDiscard] + public function useFileWatch(Watch $watch): self + { + return new self( + $this->clock, + $this->mapClock, + $this->io, + $this->halt, + $this->mapHalt, + $this->path, + $this->httpTransport, + $this->mapHttpTransport, + $this->sql, + $this->mapSql, + $this->serverControl, + $this->mapServerControl, + $this->serverStatus, + $this->mapServerStatus, + $watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -571,6 +616,7 @@ public function mapFileWatch(\Closure $map): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, static fn(Watch $watch, self $config) => $map( $previous($watch, $config), $config, @@ -604,6 +650,7 @@ public function mountFilesystemVia(\Closure $filesystem): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $filesystem, $this->mapFilesystem, @@ -636,6 +683,7 @@ public function mapFilesystem(\Closure $map): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, static fn(Filesystem $filesystem, self $config) => $map( @@ -667,6 +715,7 @@ public function handleSignalsVia(Handler $handler): self $this->mapServerControl, $this->serverStatus, $this->mapServerStatus, + $this->watch, $this->mapFileWatch, $this->filesystem, $this->mapFilesystem, @@ -801,9 +850,12 @@ public function serverStatus(Control\Server $server): Status\Server * @internal */ #[\NoDiscard] - public function fileWatch(Watch $watch): Watch + public function fileWatch(Control\Server\Processes $processes): Watch { - return ($this->mapFileWatch)($watch, $this); + return ($this->mapFileWatch)( + $this->watch ?? Watch::of($processes, $this->halt()), + $this, + ); } /** diff --git a/src/Filesystem.php b/src/Filesystem.php index 7b4b78c..dc0ebff 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -13,7 +13,6 @@ use Innmind\Server\Control\Server\Processes; use Innmind\FileWatch\{ Ping, - Factory, Watch, }; use Innmind\Immutable\{ @@ -32,9 +31,7 @@ final class Filesystem private function __construct(Processes $processes, Config $config) { - $this->watch = $config->fileWatch( - Factory::build($processes, $config->halt()), - ); + $this->watch = $config->fileWatch($processes); $this->config = $config; /** @var \WeakMap */ $this->mounted = new \WeakMap; From e6f879916c472e8158857f7ddb6131b57af23e50 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 11 Dec 2025 13:30:58 +0100 Subject: [PATCH 09/10] remove warnings --- tests/RemoteTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/RemoteTest.php b/tests/RemoteTest.php index cb024c6..d42e92c 100644 --- a/tests/RemoteTest.php +++ b/tests/RemoteTest.php @@ -46,7 +46,7 @@ public function testSsh() $remoteServer = $remote->ssh(Url::of('ssh://user@my-vps:42/')); $this->assertInstanceOf(Server::class, $remoteServer); - $remoteServer + $_ = $remoteServer ->processes() ->execute(Command::foreground('ls')) ->unwrap(); @@ -62,7 +62,7 @@ public function testSshLogger() $remoteServer = $remote->ssh(Url::of('ssh://user@my-vps:42/')); $this->assertInstanceOf(Server::class, $remoteServer); - $remoteServer + $_ = $remoteServer ->processes() ->execute(Command::foreground('ls')) ->unwrap(); @@ -78,7 +78,10 @@ public function testSshWithoutPort() $remoteServer = $remote->ssh(Url::of('ssh://user@my-vps/')); $this->assertInstanceOf(Server::class, $remoteServer); - $remoteServer->processes()->execute(Command::foreground('ls')); + $_ = $remoteServer + ->processes() + ->execute(Command::foreground('ls')) + ->unwrap(); } public function testSocket() From 7299e18bb3f666bdb32c3b5564226a9591f7570a Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 11 Dec 2025 13:31:10 +0100 Subject: [PATCH 10/10] use innmind/io to require files --- src/Filesystem.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Filesystem.php b/src/Filesystem.php index dc0ebff..aec3826 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -105,19 +105,11 @@ public function contains(Path $path): bool #[\NoDiscard] public function require(Path $path): Maybe { - $path = $path->toString(); - - if (!\file_exists($path) || \is_dir($path)) { - /** @var Maybe */ - return Maybe::nothing(); - } - - /** - * @psalm-suppress UnresolvableInclude - * @psalm-suppress MixedArgument - * @var Maybe - */ - return Maybe::just(require $path); + return $this + ->config + ->io() + ->files() + ->require($path); } #[\NoDiscard]