Skip to content

Commit

Permalink
GuzzleStreamFactory: support guzzle/psr7 version 2 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored Aug 3, 2021
1 parent 887734d commit 295c828
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.11.2] - 2021-08-03

- Support GuzzleHttp/Psr7 version 2.0 in the (deprecated) GuzzleStreamFactory.

## [1.11.1] - 2021-05-24

- Support GuzzleHttp/Psr7 version 2.0 in the (deprecated) GuzzleUriFactory.
Expand Down
5 changes: 5 additions & 0 deletions src/StreamFactory/GuzzleStreamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Http\Message\StreamFactory;

use GuzzleHttp\Psr7\Utils;
use Http\Message\StreamFactory;

/**
Expand All @@ -18,6 +19,10 @@ final class GuzzleStreamFactory implements StreamFactory
*/
public function createStream($body = null)
{
if (class_exists(Utils::class)) {
return Utils::streamFor($body);
}

return \GuzzleHttp\Psr7\stream_for($body);
}
}

2 comments on commit 295c828

@GrahamCampbell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class also exists in version 1.

@dbu
Copy link
Contributor

@dbu dbu commented on 295c828 Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but only from version 1.7 on, see e.g. https://github.com/guzzle/psr7/blob/1.6.0/src/Utils.php (that is a 404 because Utils was not yet added)

the code now does the same as the GuzzleUriFactory, i think it is the correct thing to do as we don't know the exact guzzle psr7 version.

Please sign in to comment.