From ec44ac6e33680d09132488f91b1be91b1ffe33f9 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Tue, 20 Jul 2021 07:18:47 -0500 Subject: [PATCH 1/3] Require PHP 7.3 or newer --- .travis.yml | 3 +-- composer.json | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1110807..ba0d99f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 7.2 - 7.3 - 7.4 - 8.0 @@ -18,7 +17,7 @@ git: matrix: include: - - php: 7.2 + - php: 7.3 env: - COMPOSER_FLAGS="--prefer-stable --prefer-lowest" diff --git a/composer.json b/composer.json index 1354735..a1ee758 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "psr/http-factory-implementation": "^1.0" }, "require": { + "php": ">=7.3", "psr/http-factory": "^1.0", "guzzlehttp/psr7": "^1.4.2||^2.0" }, From 062421d138798cc249ed043bf88488febce16e2b Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Tue, 20 Jul 2021 07:19:20 -0500 Subject: [PATCH 2/3] Upgrade phpunit --- .gitignore | 1 + composer.json | 2 +- phpunit.xml.dist | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index e2c2927..99cc548 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.phpunit.result.cache composer.phar composer.lock phpunit.xml diff --git a/composer.json b/composer.json index a1ee758..af72708 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 356f482..ebc5642 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,23 @@ - + + + + + src/ + + + + + + + + + + vendor/http-interop/http-factory-tests/test @@ -12,14 +31,4 @@ - - - ./src/ - - - - - - - From 89c38c31e611897da3a71b19bd5a61903609127d Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Tue, 20 Jul 2021 07:19:32 -0500 Subject: [PATCH 3/3] Switch to future-compatible Guzzle --- composer.json | 2 +- src/StreamFactory.php | 21 +-------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index af72708..863ffbd 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": ">=7.3", "psr/http-factory": "^1.0", - "guzzlehttp/psr7": "^1.4.2||^2.0" + "guzzlehttp/psr7": "^1.7||^2.0" }, "require-dev": { "http-interop/http-factory-tests": "^0.9", diff --git a/src/StreamFactory.php b/src/StreamFactory.php index d989854..6fe772e 100644 --- a/src/StreamFactory.php +++ b/src/StreamFactory.php @@ -7,39 +7,20 @@ use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; -use function GuzzleHttp\Psr7\stream_for; -use function GuzzleHttp\Psr7\try_fopen; - class StreamFactory implements StreamFactoryInterface { public function createStream(string $content = ''): StreamInterface { - if (\function_exists('stream_for')) { - // fallback for guzzlehttp/psr7<1.7.0 - return stream_for($content); - } return Utils::streamFor($content); } public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface { - if (\function_exists('try_fopen') && \function_exists('steam_for')) { - // fallback for guzzlehttp/psr7<1.7.0 - $resource = try_fopen($file, $mode); - - return stream_for($resource); - } - $resource = Utils::tryFopen($file, $mode); - - return new Stream($resource); + return $this->createStreamFromResource(Utils::tryFopen($file, $mode)); } public function createStreamFromResource($resource): StreamInterface { - if (\function_exists('stream_for')) { - // fallback for guzzlehttp/psr7<1.7.0 - return stream_for($resource); - } return new Stream($resource); } }