File tree 4 files changed +38
-5
lines changed
4 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
- ## 1.5.2 - 2023-05-23
3
+ ## 1.6.0 - 2023-05-21
4
+
5
+ ### Fixed
6
+
7
+ - We actually did fallback to the legacy message factory discovery so 1.5.2 is broken.
8
+ Changed to use PSR 17 factory discovery.
9
+ If you allow the composer plugin of ` php-http/discovery ` , things will work out of the box.
10
+ When disabled and you do not have a PSR-17 factory installed, you will need to explicitly require one, e.g. ` nyholm/psr7 ` .
11
+
12
+ ## 1.5.2 - 2023-05-17
13
+
14
+ ** Broken, use 1.6.0 instead**
4
15
5
16
### Removed
6
17
Original file line number Diff line number Diff line change 18
18
"require" : {
19
19
"php" : " ^7.1 || ^8.0" ,
20
20
"php-http/client-common" : " ^2.0" ,
21
- "php-http/discovery" : " ^1.0 " ,
21
+ "php-http/discovery" : " ^1.16 " ,
22
22
"php-http/httplug" : " ^2.0" ,
23
23
"psr/http-client" : " ^1.0" ,
24
- "psr/http-factory" : " ^1.0" ,
24
+ "psr/http-factory-implementation " : " ^1.0" ,
25
25
"psr/http-message" : " ^1.0 || ^2.0" ,
26
26
"symfony/polyfill-php80" : " ^1.17"
27
27
},
34
34
"phpspec/phpspec" : " ^5.1 || ^6.1 || ^7.3"
35
35
},
36
36
"config" : {
37
- "sort-packages" : true
37
+ "sort-packages" : true ,
38
+ "allow-plugins" : {
39
+ "php-http/discovery" : true
40
+ }
38
41
},
39
42
"autoload" : {
40
43
"psr-4" : {
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ function let(ResponseFactoryInterface $responseFactory)
22
22
function it_is_initializable ()
23
23
{
24
24
$ this ->shouldHaveType (Client::class);
25
+
26
+ // make sure the client is also instantiable without arguments
27
+ new Client ();
25
28
}
26
29
27
30
function it_is_an_http_client ()
Original file line number Diff line number Diff line change 6
6
use Http \Client \Exception ;
7
7
use Http \Client \HttpAsyncClient ;
8
8
use Http \Client \HttpClient ;
9
+ use Http \Discovery \Exception \NotFoundException ;
9
10
use Http \Discovery \MessageFactoryDiscovery ;
11
+ use Http \Discovery \Psr17FactoryDiscovery ;
10
12
use Http \Message \RequestMatcher ;
11
13
use Http \Message \ResponseFactory ;
12
14
use Psr \Http \Client \ClientExceptionInterface ;
@@ -72,7 +74,21 @@ public function __construct($responseFactory = null)
72
74
);
73
75
}
74
76
75
- $ this ->responseFactory = $ responseFactory ?: MessageFactoryDiscovery::find ();
77
+ if ($ responseFactory ) {
78
+ $ this ->responseFactory = $ responseFactory ;
79
+
80
+ return ;
81
+ }
82
+ try {
83
+ $ this ->responseFactory = Psr17FactoryDiscovery::findResponseFactory ();
84
+ } catch (NotFoundException $ notFoundException ) {
85
+ try {
86
+ $ this ->responseFactory = MessageFactoryDiscovery::find ();
87
+ } catch (NotFoundException $ e ) {
88
+ // throw the psr-17 exception to make people install the new way and not the old
89
+ throw $ notFoundException ;
90
+ }
91
+ }
76
92
}
77
93
78
94
/**
You can’t perform that action at this time.
0 commit comments