diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa48d86..9e4a616 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest] - php-version: ['8.1', '8.2', '8.3'] + php-version: ['8.2', '8.3'] dependencies: ['lowest', 'highest'] name: 'PHPUnit' steps: @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.1', '8.2', '8.3'] + php-version: ['8.2', '8.3'] dependencies: ['lowest', 'highest'] name: 'Psalm' steps: @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.1'] + php-version: ['8.2'] name: 'CS' steps: - name: Checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b26cfa..04c9a9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires `innmind/operating-system:~4.0` + +### Removed + +- Support for PHP `8.1` + ## 6.1.0 - 2023-09-23 ### Added diff --git a/composer.json b/composer.json index a719094..c235387 100644 --- a/composer.json +++ b/composer.json @@ -23,10 +23,10 @@ } }, "require": { - "php": "~8.1", + "php": "~8.2", "innmind/url": "~4.1", "innmind/immutable": "~4.13|~5.0", - "innmind/http-transport": "~6.5" + "innmind/http-transport": "~7.0" }, "require-dev": { "phpunit/phpunit": "~9.0", diff --git a/src/Directives.php b/src/Directives.php index 3aa0141..4936d1a 100644 --- a/src/Directives.php +++ b/src/Directives.php @@ -152,7 +152,7 @@ public function asContent(): Content ), ); - return Content\Lines::of($lines); + return Content::ofLines($lines); } private function allows(string $url): bool diff --git a/src/Parser.php b/src/Parser.php index 21d4dab..5d269ae 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -7,8 +7,8 @@ use Innmind\HttpTransport\Transport; use Innmind\Url\Url; use Innmind\Http\{ - Message\Request\Request, - Message\Method, + Request, + Method, ProtocolVersion, Headers, Header, @@ -37,7 +37,7 @@ private function __construct( public function __invoke(Url $url): Maybe { return ($this->fulfill)( - new Request( + Request::of( $url, Method::get, ProtocolVersion::v20, diff --git a/src/RobotsTxt.php b/src/RobotsTxt.php index 0c9b320..7a0fdac 100644 --- a/src/RobotsTxt.php +++ b/src/RobotsTxt.php @@ -64,7 +64,7 @@ public function disallows(string $userAgent, Url $url): bool public function asContent(): Content { - return Content\Lines::of( + return Content::ofLines( $this ->directives ->map(static fn($directive) => $directive->asContent()) diff --git a/src/UserAgent.php b/src/UserAgent.php index e4e3641..55b24d7 100644 --- a/src/UserAgent.php +++ b/src/UserAgent.php @@ -58,7 +58,7 @@ public function matches(string $userAgent): bool public function asContent(): Content { - return Content\Lines::of( + return Content::ofLines( $this ->agents ->map(static fn($agent) => $agent->prepend('User-agent: ')) diff --git a/tests/ParserTest.php b/tests/ParserTest.php index ec60f78..8c6894e 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -15,10 +15,11 @@ }; use Innmind\Filesystem\File\Content; use Innmind\Url\Url; -use Innmind\Http\Message\{ +use Innmind\Http\{ Request, - StatusCode, Response, + Response\StatusCode, + ProtocolVersion, }; use Innmind\Immutable\Either; use PHPUnit\Framework\TestCase; @@ -32,31 +33,25 @@ public function testExecution() 'InnmindCrawler', ); $url = Url::of('http://example.com'); - $response = $this->createMock(Response::class); - $response - ->expects($this->once()) - ->method('statusCode') - ->willReturn(StatusCode::ok); - $response - ->expects($this->once()) - ->method('body') - ->willReturn( - Content\Lines::ofContent(<<expects($this->once()) ->method('__invoke') @@ -71,8 +66,8 @@ public function testExecution() ) && $request->body()->toString() === ''; })) - ->willReturn(Either::right(new Success( - $this->createMock(Request::class), + ->willReturnCallback(static fn($request) => Either::right(new Success( + $request, $response, ))); $expected = 'User-agent: Foo'."\n"; @@ -101,19 +96,15 @@ public function testThrowWhenRequestNotFulfilled() 'InnmindCrawler', ); $url = Url::of('http://example.com'); - $response = $this->createMock(Response::class); - $response - ->expects($this->once()) - ->method('statusCode') - ->willReturn(StatusCode::notFound); - $response - ->expects($this->never()) - ->method('body'); + $response = Response::of( + StatusCode::notFound, + ProtocolVersion::v11, + ); $transport ->expects($this->once()) ->method('__invoke') - ->willReturn(Either::left(new ClientError( - $this->createMock(Request::class), + ->willReturnCallback(static fn($request) => Either::left(new ClientError( + $request, $response, )));