diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6de16f7..9c1509fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: strategy: max-parallel: 10 matrix: - php: ['7.2', '7.3', '7.4'] + php: ['7.2', '7.3', '7.4', '8.0'] sf_version: ['3.4.*', '4.4.*', '5.0.*'] steps: @@ -103,7 +103,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@2.1.0 with: - php-version: 7.3 + php-version: 7.4 tools: flex - name: Checkout code @@ -122,7 +122,7 @@ jobs: - name: Run tests run: | - docker run --rm --net buzz-bridge -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e BUZZ_TEST_SERVER=http://test-server/index.php tommymuehle/docker-alpine-php-nightly php vendor/bin/phpunit + docker run --rm --net buzz-bridge -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e BUZZ_TEST_SERVER=http://test-server/index.php php:7.4-cli php vendor/bin/phpunit lowest: name: Lowest deps diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 321ff23c..70145885 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -42,6 +42,6 @@ jobs: uses: actions/checkout@v2 - name: Psalm - uses: docker://muglug/psalm-github-actions + uses: docker://vimeo/psalm-github-actions with: args: --no-progress --show-info=false --stats diff --git a/Dockerfile b/Dockerfile index 5f26f56b..d99f8cbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.3-fpm-stretch +FROM php:7.4-fpm-buster # Install Nginx RUN apt-get update -qq && apt-get install -y --no-install-recommends -qq nginx diff --git a/composer.json b/composer.json index 6c478fc0..3843c04f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "psr/http-message": "^1.0", "psr/http-client": "^1.0", "php-http/httplug": "^1.1 || ^2.0", @@ -26,10 +26,10 @@ "psr/http-factory": "^1.0" }, "require-dev": { - "php-http/client-integration-tests": "^2.0.1", + "php-http/client-integration-tests": "^3.0", "nyholm/psr7": "^1.0", "psr/log": "^1.0", - "phpunit/phpunit": "7.5.20" + "phpunit/phpunit": "^7.5 || ^9.4" }, "provide": { "php-http/client-implementation": "1.0", diff --git a/lib/Client/AbstractClient.php b/lib/Client/AbstractClient.php index 50cc5852..e63abb9a 100644 --- a/lib/Client/AbstractClient.php +++ b/lib/Client/AbstractClient.php @@ -13,7 +13,7 @@ abstract class AbstractClient { /** - * @var OptionsResolver + * @var OptionsResolver|null */ private $optionsResolver; diff --git a/lib/Client/MultiCurl.php b/lib/Client/MultiCurl.php index c8e04e88..01785b55 100644 --- a/lib/Client/MultiCurl.php +++ b/lib/Client/MultiCurl.php @@ -56,7 +56,13 @@ public function __construct($responseFactory, array $options = []) { parent::__construct($responseFactory, $options); - if (\PHP_VERSION_ID < 70215 || \PHP_VERSION_ID === 70300 || \PHP_VERSION_ID === 70301 || !(CURL_VERSION_HTTP2 & curl_version()['features'])) { + if ( + \PHP_VERSION_ID < 70215 || + \PHP_VERSION_ID === 70300 || + \PHP_VERSION_ID === 70301 || + \PHP_VERSION_ID >= 80000 || + !(CURL_VERSION_HTTP2 & curl_version()['features']) + ) { // Dont use HTTP/2 push when it's unsupported or buggy, see https://bugs.php.net/76675 $this->serverPushSupported = false; } diff --git a/tests/Integration/BaseIntegrationTest.php b/tests/Integration/BaseIntegrationTest.php index a71cbf6e..9a4fab01 100644 --- a/tests/Integration/BaseIntegrationTest.php +++ b/tests/Integration/BaseIntegrationTest.php @@ -8,7 +8,7 @@ abstract class BaseIntegrationTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (getenv('BUZZ_TEST_SERVER')) { diff --git a/tests/Integration/BuzzIntegrationTest.php b/tests/Integration/BuzzIntegrationTest.php index 2f937c43..902732b5 100644 --- a/tests/Integration/BuzzIntegrationTest.php +++ b/tests/Integration/BuzzIntegrationTest.php @@ -21,7 +21,7 @@ class BuzzIntegrationTest extends BaseIntegrationTest { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (empty($_SERVER['BUZZ_TEST_SERVER'])) { @@ -125,7 +125,7 @@ public function testFormPostWithRequestBuilder($client, $async) $this->assertNotEmpty($response->getBody()->__toString(), 'Response from server should not be empty'); $data = json_decode($response->getBody()->__toString(), true); - $this->assertInternalType('array', $data, $response->getBody()->__toString()); + $this->assertIsArray($data, $response->getBody()->__toString()); $this->assertArrayHasKey('SERVER', $data); $this->assertStringStartsWith('multipart/form-data', $data['SERVER']['CONTENT_TYPE']); @@ -156,7 +156,7 @@ public function testFormPostWithLargeRequestBody($client, $async) $this->assertNotEmpty($response->getBody()->__toString(), 'Response from server should not be empty'); $data = json_decode($response->getBody()->__toString(), true); - $this->assertInternalType('array', $data, $response->getBody()->__toString()); + $this->assertIsArray($data, $response->getBody()->__toString()); $this->assertArrayHasKey('SERVER', $data); $this->assertStringStartsWith('multipart/form-data', $data['SERVER']['CONTENT_TYPE']); diff --git a/tests/Integration/Httplug/BaseIntegrationTest.php b/tests/Integration/Httplug/BaseIntegrationTest.php index 55e1fb95..38c9a8bd 100644 --- a/tests/Integration/Httplug/BaseIntegrationTest.php +++ b/tests/Integration/Httplug/BaseIntegrationTest.php @@ -9,7 +9,7 @@ abstract class BaseIntegrationTest extends HttpClientTest { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (false === PHPUnitUtility::getUri()) { diff --git a/tests/Integration/Httplug/BrowserIntegrationTest.php b/tests/Integration/Httplug/BrowserIntegrationTest.php index 54ac90c0..661cf082 100644 --- a/tests/Integration/Httplug/BrowserIntegrationTest.php +++ b/tests/Integration/Httplug/BrowserIntegrationTest.php @@ -7,10 +7,11 @@ use Buzz\Browser; use Buzz\Client\FileGetContents; use Nyholm\Psr7\Factory\Psr17Factory; +use Psr\Http\Client\ClientInterface; class BrowserIntegrationTest extends BaseIntegrationTest { - protected function createHttpAdapter() + protected function createHttpAdapter(): ClientInterface { $client = new FileGetContents(new Psr17Factory(), []); $browser = new Browser($client, new Psr17Factory()); diff --git a/tests/Integration/Httplug/CurlIntegrationTest.php b/tests/Integration/Httplug/CurlIntegrationTest.php index c43f7cdf..5ee7fdbc 100644 --- a/tests/Integration/Httplug/CurlIntegrationTest.php +++ b/tests/Integration/Httplug/CurlIntegrationTest.php @@ -6,10 +6,11 @@ use Buzz\Client\Curl; use Nyholm\Psr7\Factory\Psr17Factory; +use Psr\Http\Client\ClientInterface; class CurlIntegrationTest extends BaseIntegrationTest { - protected function createHttpAdapter() + protected function createHttpAdapter(): ClientInterface { return new Curl(new Psr17Factory(), []); } diff --git a/tests/Integration/Httplug/FileGetContentsIntegrationTest.php b/tests/Integration/Httplug/FileGetContentsIntegrationTest.php index d1740c1c..00bd80f8 100644 --- a/tests/Integration/Httplug/FileGetContentsIntegrationTest.php +++ b/tests/Integration/Httplug/FileGetContentsIntegrationTest.php @@ -6,10 +6,11 @@ use Buzz\Client\FileGetContents; use Nyholm\Psr7\Factory\Psr17Factory; +use Psr\Http\Client\ClientInterface; class FileGetContentsIntegrationTest extends BaseIntegrationTest { - protected function createHttpAdapter() + protected function createHttpAdapter(): ClientInterface { return new FileGetContents(new Psr17Factory(), []); } diff --git a/tests/Integration/Httplug/MultiCurlIntegrationTest.php b/tests/Integration/Httplug/MultiCurlIntegrationTest.php index 324ff087..ecdfa407 100644 --- a/tests/Integration/Httplug/MultiCurlIntegrationTest.php +++ b/tests/Integration/Httplug/MultiCurlIntegrationTest.php @@ -6,10 +6,11 @@ use Buzz\Client\MultiCurl; use Nyholm\Psr7\Factory\Psr17Factory; +use Psr\Http\Client\ClientInterface; class MultiCurlIntegrationTest extends BaseIntegrationTest { - protected function createHttpAdapter() + protected function createHttpAdapter(): ClientInterface { return new MultiCurl(new Psr17Factory(), []); } diff --git a/tests/Integration/MultiCurlServerPushTest.php b/tests/Integration/MultiCurlServerPushTest.php index 5f3257a8..0d386423 100644 --- a/tests/Integration/MultiCurlServerPushTest.php +++ b/tests/Integration/MultiCurlServerPushTest.php @@ -10,10 +10,10 @@ class MultiCurlServerPushTest extends BaseIntegrationTest { - protected function setUp() + protected function setUp(): void { parent::setUp(); - if (\PHP_VERSION_ID < 70400 || curl_version()['version_number'] < 472065) { + if (\PHP_VERSION_ID < 70400 || \PHP_VERSION_ID >= 80000 || curl_version()['version_number'] < 472065) { $this->markTestSkipped('This environment does not support server push'); } } diff --git a/tests/Integration/MultiCurlTest.php b/tests/Integration/MultiCurlTest.php index 776cdb54..35723531 100644 --- a/tests/Integration/MultiCurlTest.php +++ b/tests/Integration/MultiCurlTest.php @@ -11,7 +11,7 @@ class MultiCurlTest extends BaseIntegrationTest { - protected function setUp() + protected function setUp(): void { parent::setUp(); if (empty($_SERVER['BUZZ_TEST_SERVER'])) { diff --git a/tests/Unit/BrowserTest.php b/tests/Unit/BrowserTest.php index f9702c1e..83eec31b 100644 --- a/tests/Unit/BrowserTest.php +++ b/tests/Unit/BrowserTest.php @@ -20,7 +20,7 @@ class BrowserTest extends TestCase /** @var Browser */ private $browser; - protected function setUp() + protected function setUp(): void { $this->client = $this->getMockBuilder('Buzz\Client\Curl') ->disableOriginalConstructor() @@ -112,7 +112,7 @@ public function testSubmitForm(array $fields, array $headers, array $requestHead $regex = substr($requestBody, 5); $regex = str_replace("\n", "\r\n", $regex); - return preg_match($regex, $input); + return false !== preg_match($regex, $input); }; $browser = $this->getMockBuilder(Browser::class) diff --git a/tests/Unit/Middleware/History/JournalTest.php b/tests/Unit/Middleware/History/JournalTest.php index 8b88f39a..bc2c865e 100644 --- a/tests/Unit/Middleware/History/JournalTest.php +++ b/tests/Unit/Middleware/History/JournalTest.php @@ -23,7 +23,7 @@ class JournalTest extends TestCase protected $response3; - protected function setUp() + protected function setUp(): void { $this->request1 = new Request('GET', '/r1', [], 'request1'); $this->request2 = new Request('GET', '/r2', [], 'request2'); @@ -33,7 +33,7 @@ protected function setUp() $this->response3 = new Response(200, [], 'response3'); } - protected function tearDown() + protected function tearDown(): void { $this->request1 = null; $this->request2 = null; diff --git a/tests/Unit/Middleware/HistoryMiddlewareTest.php b/tests/Unit/Middleware/HistoryMiddlewareTest.php index 0feab1c8..4f25fc83 100644 --- a/tests/Unit/Middleware/HistoryMiddlewareTest.php +++ b/tests/Unit/Middleware/HistoryMiddlewareTest.php @@ -16,7 +16,7 @@ class HistoryMiddlewareTest extends TestCase /** @var HistoryMiddleware */ private $middleware; - protected function setUp() + protected function setUp(): void { $this->journal = $this->getMockBuilder('Buzz\Middleware\History\Journal') ->disableOriginalConstructor() diff --git a/tests/Unit/Middleware/LoggerMiddlewareTest.php b/tests/Unit/Middleware/LoggerMiddlewareTest.php index ec503b30..1fe253ec 100644 --- a/tests/Unit/Middleware/LoggerMiddlewareTest.php +++ b/tests/Unit/Middleware/LoggerMiddlewareTest.php @@ -19,7 +19,14 @@ public function testLogger() // TODO Use PSR3 logger $logger = new CallbackLogger(function ($level, $message, array $context) use ($that) { - $that->assertRegExp('~^Sent "GET http://google.com/" in \d+ms$~', $message); + $pattern = '~^Sent "GET http://google.com/" in \d+ms$~'; + if (method_exists($this, 'assertMatchesRegularExpression')) { + $that->assertMatchesRegularExpression($pattern, $message); + + return; + } + // phpunit 7 compatibility + $that->assertRegExp($pattern, $message); }); $request = new Request('GET', 'http://google.com/'); diff --git a/tests/Unit/Middleware/WsseAuthMiddlewareTest.php b/tests/Unit/Middleware/WsseAuthMiddlewareTest.php index d7a80531..ffccf4c3 100644 --- a/tests/Unit/Middleware/WsseAuthMiddlewareTest.php +++ b/tests/Unit/Middleware/WsseAuthMiddlewareTest.php @@ -22,6 +22,13 @@ public function testBasicAuthHeader() $this->assertEquals('WSSE profile="UsernameToken"', $newRequest->getHeaderLine('Authorization')); $wsse = $newRequest->getHeaderLine('X-WSSE'); - $this->assertRegExp('|UsernameToken Username="foo", PasswordDigest=".+?", Nonce=".+?", Created=".+?"|', $wsse); + $pattern = '|UsernameToken Username="foo", PasswordDigest=".+?", Nonce=".+?", Created=".+?"|'; + if (method_exists($this, 'assertMatchesRegularExpression')) { + $this->assertMatchesRegularExpression($pattern, $wsse); + + return; + } + // phpunit 7 compatibility + $this->assertRegExp($pattern, $wsse); } }