diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 189105d..2f3eecb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,5 +12,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' diff --git a/CHANGELOG.md b/CHANGELOG.md index d09dff0..2d99c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires PHP `8.4` +- Requires `innmind/foundation:~2.1` + ## 5.4.0 - 2025-07-31 ### Changed diff --git a/composer.json b/composer.json index 8ec6496..2b7bd44 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,8 @@ "issues": "http://github.com/Innmind/LogReader/issues" }, "require": { - "php": "~8.2", - "innmind/foundation": "~1.3", + "php": "~8.4", + "innmind/foundation": "~2.1", "psr/log": "^3.0" }, "autoload": { @@ -30,7 +30,7 @@ }, "require-dev": { "innmind/black-box": "^6.4.1", - "innmind/static-analysis": "^1.2.1", + "innmind/static-analysis": "~1.3", "innmind/coding-standard": "~2.0" } } diff --git a/src/LineParser/ApacheAccess.php b/src/LineParser/ApacheAccess.php index bc8ef92..639b43d 100644 --- a/src/LineParser/ApacheAccess.php +++ b/src/LineParser/ApacheAccess.php @@ -8,9 +8,9 @@ Log, Log\Attribute\Attribute, }; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, - PointInTime, + Point, Format, }; use Innmind\Url\{ @@ -63,7 +63,9 @@ public function __invoke(Str $line): Maybe ->get('time') ->map(static fn($time) => $time->toString()) ->keep(Is::string()->nonEmpty()->asPredicate()) - ->flatMap($this->clock->ofFormat(Format::of('d/M/Y:H:i:s O'))->at(...)); + ->attempt(static fn() => new \Exception) + ->flatMap($this->clock->ofFormat(Format::of('d/M/Y:H:i:s O'))->at(...)) + ->maybe(); $user = $parts ->get('user') ->map(static fn($user) => Attribute::of('user', $user)); @@ -106,7 +108,7 @@ public function __invoke(Str $line): Maybe $code, $size, ) - ->map(static fn(PointInTime $time, Attribute ...$attributes) => Log::of( + ->map(static fn(Point $time, Attribute ...$attributes) => Log::of( $time, $line, Set::of(...$attributes), diff --git a/src/LineParser/Monolog.php b/src/LineParser/Monolog.php index 68b0ba1..00b5b55 100644 --- a/src/LineParser/Monolog.php +++ b/src/LineParser/Monolog.php @@ -11,7 +11,7 @@ Log\Attribute\Monolog\Level, Log\Attribute\Monolog\Message, }; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, Format, }; @@ -101,7 +101,9 @@ public function __invoke(Str $line): Maybe ->get('time') ->map(static fn($time) => $time->toString()) ->keep(Is::string()->nonEmpty()->asPredicate()) - ->flatMap($this->clock->ofFormat(Format::of('Y-m-d H:i:s'))->at(...)); + ->attempt(static fn() => new \Exception) + ->flatMap($this->clock->ofFormat(Format::of('Y-m-d H:i:s'))->at(...)) + ->maybe(); return $time->flatMap( static fn($time) => $attributes->map( diff --git a/src/Log.php b/src/Log.php index 3d5942b..fd30665 100644 --- a/src/Log.php +++ b/src/Log.php @@ -4,7 +4,7 @@ namespace Innmind\LogReader; use Innmind\LogReader\Log\Attribute; -use Innmind\TimeContinuum\PointInTime; +use Innmind\Time\Point; use Innmind\Immutable\{ Str, Set, @@ -16,7 +16,7 @@ */ final class Log { - private PointInTime $time; + private Point $time; private Str $raw; /** @var Set */ private Set $attributes; @@ -24,7 +24,7 @@ final class Log /** * @param Set $attributes */ - private function __construct(PointInTime $time, Str $raw, Set $attributes) + private function __construct(Point $time, Str $raw, Set $attributes) { $this->time = $time; $this->raw = $raw; @@ -36,13 +36,13 @@ private function __construct(PointInTime $time, Str $raw, Set $attributes) * * @param Set $attributes */ - public static function of(PointInTime $time, Str $raw, Set $attributes): self + public static function of(Point $time, Str $raw, Set $attributes): self { return new self($time, $raw, $attributes); } #[\NoDiscard] - public function time(): PointInTime + public function time(): Point { return $this->time; } diff --git a/tests/LineParser/ApacheAccessTest.php b/tests/LineParser/ApacheAccessTest.php index 5667eef..e1fedd2 100644 --- a/tests/LineParser/ApacheAccessTest.php +++ b/tests/LineParser/ApacheAccessTest.php @@ -8,7 +8,7 @@ LineParser, Log, }; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, Format, }; @@ -24,6 +24,7 @@ use Innmind\Immutable\Str; use PHPUnit\Framework\Attributes\DataProvider; use Innmind\BlackBox\PHPUnit\Framework\TestCase; +use Composer\InstalledVersions; class ApacheAccessTest extends TestCase { @@ -35,6 +36,16 @@ public function testInterface() #[DataProvider('lines')] public function testInvokation($line, $client, $user, $time, $method, $path, $protocol, $code, $size) { + if (\is_array($path)) { + [$v84, $v85] = $path; + + if (\str_starts_with(InstalledVersions::getVersion('innmind/url'), '5.0')) { + $path = $v84; + } else { + $path = $v85; + } + } + $parse = ApacheAccess::of( Clock::live()->switch(static fn($timezones) => $timezones->utc()), ); @@ -220,7 +231,10 @@ public static function lines(): array '-', '2004-03-08T00:23:12+00:00', 'GET', - '/twiki/bin/oops/TWiki/AppendixFileSystem?template=oopsmore¶m1=1.12¶m2=1.12', + [ + '/twiki/bin/oops/TWiki/AppendixFileSystem?template=oopsmore¶m1=1.12¶m2=1.12', + '/twiki/bin/oops/TWiki/AppendixFileSystem?template=oopsmore%C2%B6m1=1.12%C2%B6m2=1.12', + ], '1.1', '200', 11382, diff --git a/tests/LineParser/MonologTest.php b/tests/LineParser/MonologTest.php index 2cd12ee..f03fe3b 100644 --- a/tests/LineParser/MonologTest.php +++ b/tests/LineParser/MonologTest.php @@ -11,7 +11,7 @@ Log\Attribute\Monolog\Level, Log\Attribute\Monolog\Message, }; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, Format, }; diff --git a/tests/LogTest.php b/tests/LogTest.php index 0b09ef0..c838c01 100644 --- a/tests/LogTest.php +++ b/tests/LogTest.php @@ -7,7 +7,7 @@ Log, Log\Attribute, }; -use Innmind\TimeContinuum\PointInTime; +use Innmind\Time\Point; use Innmind\Immutable\{ Set, Str, @@ -19,7 +19,7 @@ class LogTest extends TestCase public function testInterface() { $log = Log::of( - $time = PointInTime::now(), + $time = Point::now(), $raw = Str::of('foo'), $attributes = Set::of(Attribute\Attribute::of('bar', 42)), ); @@ -34,12 +34,12 @@ public function testInterface() public function testEquals() { $log = Log::of( - PointInTime::now(), + Point::now(), Str::of('foo'), Set::of(), ); $log2 = Log::of( - PointInTime::now(), + Point::now(), Str::of('bar'), Set::of(), ); diff --git a/tests/ReaderTest.php b/tests/ReaderTest.php index 114c6ba..fa45ea1 100644 --- a/tests/ReaderTest.php +++ b/tests/ReaderTest.php @@ -7,9 +7,9 @@ Reader, LineParser\Monolog, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; use Innmind\Filesystem\{ - Adapter\Filesystem, + Adapter, Name, }; use Innmind\Url\Path; @@ -21,7 +21,8 @@ class ReaderTest extends TestCase public function testParse() { $read = Reader::of(Monolog::of(Clock::live())); - $file = Filesystem::mount(Path::of('fixtures/')) + $file = Adapter::mount(Path::of('fixtures/')) + ->unwrap() ->get(Name::of('symfony.log')) ->match( static fn($file) => $file->content(), @@ -31,6 +32,6 @@ public function testParse() $stream = $read($file); $this->assertInstanceOf(Sequence::class, $stream); - $this->assertCount(5000, $stream); + $this->assertSame(5000, $stream->size()); } }