Skip to content

Commit

Permalink
Merge pull request #15 from http-interop/chore/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
shadowhand authored Jul 21, 2021
2 parents c42a6ea + 89c38c3 commit 7a3e256
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
composer.phar
composer.lock
phpunit.xml
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.2
- 7.3
- 7.4
- 8.0
Expand All @@ -18,7 +17,7 @@ git:

matrix:
include:
- php: 7.2
- php: 7.3
env:
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
"psr/http-factory-implementation": "^1.0"
},
"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",
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
31 changes: 20 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<phpunit backupGlobals="true" bootstrap="vendor/autoload.php" colors="true">
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="true"
bootstrap="vendor/autoload.php"
colors="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
<logging>
<junit outputFile="build/phpunit/junit.xml"/>
</logging>
<testsuites>
<testsuite name="Integration tests">
<directory>vendor/http-interop/http-factory-tests/test</directory>
Expand All @@ -12,14 +31,4 @@
<const name="UPLOADED_FILE_FACTORY" value="Http\Factory\Guzzle\UploadedFileFactory"/>
<const name="URI_FACTORY" value="Http\Factory\Guzzle\UriFactory"/>
</php>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-text" target="php://stdout"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
21 changes: 1 addition & 20 deletions src/StreamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 7a3e256

Please sign in to comment.