From 780f8af4fcac867e8905e5163e11d5e183dc2a16 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 16 Nov 2025 15:12:57 +0100 Subject: [PATCH 1/7] 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 d882e56..81abe01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires PHP `8.4` + ## 5.0.0 - 2025-05-08 ### Changed diff --git a/composer.json b/composer.json index 80aa487..1933290 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "issues": "http://github.com/Innmind/FileWatch/issues" }, "require": { - "php": "~8.2", + "php": "~8.4", "innmind/url": "~4.0", "innmind/server-control": "~6.0", "innmind/time-warp": "~4.0", From 39391bb4d94b383145a1c13468ef1f0e33ed5a9a Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 16 Nov 2025 15:18:34 +0100 Subject: [PATCH 2/7] add internal Watch\Implementation --- src/Watch.php | 3 ++- src/Watch/Implementation.php | 15 +++++++++++++++ src/Watch/Kind.php | 3 ++- src/Watch/Logger.php | 18 +++++------------- 4 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 src/Watch/Implementation.php diff --git a/src/Watch.php b/src/Watch.php index 21b8272..cb0176d 100644 --- a/src/Watch.php +++ b/src/Watch.php @@ -4,6 +4,7 @@ namespace Innmind\FileWatch; use Innmind\FileWatch\Watch\{ + Implementation, Kind, Logger, Fallback, @@ -19,7 +20,7 @@ final class Watch { private function __construct( - private Kind|Logger $implementation, + private Implementation $implementation, ) { } diff --git a/src/Watch/Implementation.php b/src/Watch/Implementation.php new file mode 100644 index 0000000..57a049d --- /dev/null +++ b/src/Watch/Implementation.php @@ -0,0 +1,15 @@ +directory()) { diff --git a/src/Watch/Logger.php b/src/Watch/Logger.php index 5a6e677..df9d4a1 100644 --- a/src/Watch/Logger.php +++ b/src/Watch/Logger.php @@ -10,14 +10,15 @@ /** * @internal */ -final class Logger +final class Logger implements Implementation { private function __construct( - private Kind $watch, + private Implementation $watch, private LoggerInterface $logger, ) { } + #[\Override] public function __invoke(Path $path): Ping\Implementation { return Ping\Logger::psr( @@ -27,17 +28,8 @@ public function __invoke(Path $path): Ping\Implementation ); } - public static function psr(Kind|self $watch, LoggerInterface $logger): self + public static function psr(Implementation $watch, LoggerInterface $logger): self { - return new self(self::extract($watch), $logger); - } - - private static function extract(Kind|self $watch): Kind - { - if ($watch instanceof Kind) { - return $watch; - } - - return self::extract($watch->watch); + return new self($watch, $logger); } } From 89aba81fe8efafd2f07a47c732913b2c25724426 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Tue, 18 Nov 2025 12:03:31 +0100 Subject: [PATCH 3/7] update dependencies --- composer.json | 14 ++++++++++---- tests/FunctionalTest.php | 40 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 1933290..2b92901 100644 --- a/composer.json +++ b/composer.json @@ -16,10 +16,16 @@ }, "require": { "php": "~8.4", - "innmind/url": "~4.0", - "innmind/server-control": "~6.0", - "innmind/time-warp": "~4.0", - "innmind/time-continuum": "^4.1.1", + "innmind/url": "dev-next", + "innmind/server-control": "dev-next", + "innmind/time-warp": "dev-next", + "innmind/time-continuum": "dev-next", + "innmind/filesystem": "dev-next", + "innmind/io": "dev-next", + "innmind/media-type": "dev-next", + "innmind/validation": "dev-next", + "innmind/ip": "dev-next", + "innmind/immutable": "dev-next", "psr/log": "~3.0" }, "autoload": { diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index fb74172..c9e3b4a 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -7,12 +7,12 @@ Factory, Watch, }; -use Innmind\Server\Control\Server\{ - Processes\Unix, - Command, +use Innmind\Server\Control\{ + ServerFactory, + Server\Command, }; use Innmind\TimeContinuum\Clock; -use Innmind\TimeWarp\Halt\Usleep; +use Innmind\TimeWarp\Halt; use Innmind\IO\IO; use Innmind\Url\Path; use Psr\Log\NullLogger; @@ -34,16 +34,16 @@ public function tearDown(): void public function testWatchFile() { \touch('/tmp/innmind/watch-file'); - $processes = Unix::of( + $processes = ServerFactory::build( Clock::live(), IO::fromAmbientAuthority(), - Usleep::new(), - ); + Halt::new(), + )->processes(); $process = $processes->execute(Command::background( 'sleep 1 && echo foo >> /tmp/innmind/watch-file && sleep 1 && echo foo >> /tmp/innmind/watch-file && sleep 1 && echo foo >> /tmp/innmind/watch-file', )); - $watch = Factory::build($processes, Usleep::new()); + $watch = Factory::build($processes, Halt::new()); $either = $watch(Path::of('/tmp/innmind/watch-file'))(0, static function($count, $continuation) { ++$count; @@ -66,16 +66,16 @@ public function testWatchFile() public function testWatchDirectory() { - $processes = Unix::of( + $processes = ServerFactory::build( Clock::live(), IO::fromAmbientAuthority(), - Usleep::new(), - ); + Halt::new(), + )->processes(); $process = $processes->execute(Command::background( 'sleep 1 && touch /tmp/innmind/watch-file && sleep 1 && rm /tmp/innmind/watch-file', )); - $watch = Factory::build($processes, Usleep::new()); + $watch = Factory::build($processes, Halt::new()); $either = $watch(Path::of('/tmp/innmind/'))(0, static function($count, $continuation) { ++$count; @@ -98,13 +98,13 @@ public function testWatchDirectory() public function testReturnErrorWhenWatchingUnknownFile() { - $processes = Unix::of( + $processes = ServerFactory::build( Clock::live(), IO::fromAmbientAuthority(), - Usleep::new(), - ); + Halt::new(), + )->processes(); - $watch = Factory::build($processes, Usleep::new()); + $watch = Factory::build($processes, Halt::new()); $either = $watch(Path::of('/unknown/'))(null, static fn($_, $continuation) => $continuation); @@ -118,16 +118,16 @@ public function testReturnErrorWhenWatchingUnknownFile() public function testLog() { \touch('/tmp/innmind/watch-file'); - $processes = Unix::of( + $processes = ServerFactory::build( Clock::live(), IO::fromAmbientAuthority(), - Usleep::new(), - ); + Halt::new(), + )->processes(); $process = $processes->execute(Command::background( 'sleep 1 && echo foo >> /tmp/innmind/watch-file && sleep 1 && echo foo >> /tmp/innmind/watch-file && sleep 1 && echo foo >> /tmp/innmind/watch-file', )); - $inner = Factory::build($processes, Usleep::new()); + $inner = Factory::build($processes, Halt::new()); $watch = Watch::logger($inner, new NullLogger); $either = $watch(Path::of('/tmp/innmind/watch-file'))(0, static function($count, $continuation) { From 069bdca7bb80e96787c20ddc8f03c6b2c8c0627a Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 7 Feb 2026 11:57:14 +0100 Subject: [PATCH 4/7] tag dependencies --- .github/workflows/ci.yml | 8 ++++---- CHANGELOG.md | 1 + composer.json | 16 +++++----------- src/Ping/OutputDiff.php | 6 +++--- tests/FunctionalTest.php | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 779f162..2f3eecb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,11 +4,11 @@ on: [push, pull_request] jobs: blackbox: - uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@next + uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main coverage: - uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@next + uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main secrets: inherit psalm: - uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@next + uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: - uses: innmind/github-workflows/.github/workflows/cs.yml@next + uses: innmind/github-workflows/.github/workflows/cs.yml@main diff --git a/CHANGELOG.md b/CHANGELOG.md index 81abe01..943e601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - Requires PHP `8.4` +- Requires `innmind/server-control:~7.0` ## 5.0.0 - 2025-05-08 diff --git a/composer.json b/composer.json index 2b92901..e7ce274 100644 --- a/composer.json +++ b/composer.json @@ -16,16 +16,10 @@ }, "require": { "php": "~8.4", - "innmind/url": "dev-next", - "innmind/server-control": "dev-next", - "innmind/time-warp": "dev-next", - "innmind/time-continuum": "dev-next", - "innmind/filesystem": "dev-next", - "innmind/io": "dev-next", - "innmind/media-type": "dev-next", - "innmind/validation": "dev-next", - "innmind/ip": "dev-next", - "innmind/immutable": "dev-next", + "innmind/url": "~5.0", + "innmind/server-control": "~7.0", + "innmind/time-warp": "~5.0", + "innmind/time-continuum": "~5.0", "psr/log": "~3.0" }, "autoload": { @@ -39,7 +33,7 @@ } }, "require-dev": { - "innmind/static-analysis": "^1.2.1", + "innmind/static-analysis": "~1.3", "innmind/coding-standard": "~2.0", "innmind/black-box": "~6.1" } diff --git a/src/Ping/OutputDiff.php b/src/Ping/OutputDiff.php index e41b680..1fd6c77 100644 --- a/src/Ping/OutputDiff.php +++ b/src/Ping/OutputDiff.php @@ -49,7 +49,7 @@ public function __invoke(mixed $carry, callable $ping): Attempt $result = Sequence::lazy(function() { while (true) { yield $this->output(); - ($this->halt)($this->period); + $_ = ($this->halt)($this->period)->memoize(); } }) ->flatMap(static fn($maybe) => $maybe->match( @@ -136,11 +136,11 @@ private function diff(Sequence $previous, Sequence $now): bool { $previous = $previous ->map(static fn($chunk) => $chunk->data()) - ->fold(new Concat) + ->fold(Concat::monoid) ->toString(); $now = $now ->map(static fn($chunk) => $chunk->data()) - ->fold(new Concat) + ->fold(Concat::monoid) ->toString(); return $previous !== $now; diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index c9e3b4a..f990150 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -125,7 +125,7 @@ public function testLog() )->processes(); $process = $processes->execute(Command::background( 'sleep 1 && echo foo >> /tmp/innmind/watch-file && sleep 1 && echo foo >> /tmp/innmind/watch-file && sleep 1 && echo foo >> /tmp/innmind/watch-file', - )); + ))->unwrap(); $inner = Factory::build($processes, Halt::new()); $watch = Watch::logger($inner, new NullLogger); From 669b3b529390dd7adbe2ba853f09e7a242426003 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 7 Feb 2026 11:58:27 +0100 Subject: [PATCH 5/7] fix readme --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e8fbab6..199eb28 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,9 @@ composer require innmind/file-watch ## Usage ```php -use Innmind\FileWatch\{ - Factory, - Stop, -}; +use Innmind\FileWatch\Factory; use Innmind\Server\Control\ServerFactory; -use Innmind\TimeWarp\Halt\Usleep; +use Innmind\TimeWarp\Halt; use Innmind\TimeContinuum\Clock; use Innmind\IO\IO; use Innmind\Url\Path; @@ -30,9 +27,9 @@ $watch = Factory::build( ServerFactory::build( Clock::live(), IO::fromAmbientAuthority(), - Usleep::new(), + Halt::new(), )->processes(), - Usleep::new(), + Halt::new(), ); $count = $watch(Path::of('/to/some/file/or/folder'))(0, function(int $count, Continuation $continuation): Continuation { From b269c3d76fb2145e42b21acbe4ab0be9cca6a522 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 7 Feb 2026 11:58:52 +0100 Subject: [PATCH 6/7] fix ci badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 199eb28..2b1ea0e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # FileWatch -[![Build Status](https://github.com/innmind/filewatch/workflows/CI/badge.svg?branch=master)](https://github.com/innmind/filewatch/actions?query=workflow%3ACI) +[![CI](https://github.com/Innmind/FileWatch/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Innmind/FileWatch/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/innmind/filewatch/branch/develop/graph/badge.svg)](https://codecov.io/gh/innmind/filewatch) [![Type Coverage](https://shepherd.dev/github/innmind/filewatch/coverage.svg)](https://shepherd.dev/github/innmind/filewatch) From 12bcccb4d17b2e0fe94e6135741101c67ba56afe Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 7 Feb 2026 12:01:26 +0100 Subject: [PATCH 7/7] bump minimum versions --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e7ce274..7368bda 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ "php": "~8.4", "innmind/url": "~5.0", "innmind/server-control": "~7.0", - "innmind/time-warp": "~5.0", - "innmind/time-continuum": "~5.0", + "innmind/time-warp": "~5.1", + "innmind/time-continuum": "~5.1", "psr/log": "~3.0" }, "autoload": {