Skip to content

Commit 30aa1f0

Browse files
committed
change guzzle/psr7 to nyholm/psr7
1 parent a62472b commit 30aa1f0

13 files changed

+188
-246
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Mock for PSR-18 HTTP client
1212
Add package to project
1313

1414
```bash
15-
composer require --dev webclient/fake-http-client:^1.0
15+
composer require --dev webclient/fake-http-client:^2.0
1616
```
1717

1818
Set autoload
@@ -28,15 +28,15 @@ include 'vendor/autoload.php';
2828
```php
2929
<?php
3030

31-
use Webclient\Fake\Client;
31+
use Webclient\Fake\FakeHttpClient;
3232
use Psr\Http\Message\RequestInterface;
3333
use Psr\Http\Server\RequestHandlerInterface;
3434

3535
/**
3636
* @var RequestHandlerInterface $handler your mock handler
3737
* @var RequestInterface $request your tested request
3838
*/
39-
$client = new Client($handler);
39+
$client = new FakeHttpClient($handler);
4040

4141
$response = $client->sendRequest($request);
4242
```
@@ -48,7 +48,7 @@ This package provides simple routing.
4848
```php
4949
<?php
5050

51-
use Webclient\Fake\Client;
51+
use Webclient\Fake\FakeHttpClient;
5252
use Webclient\Fake\Handler\SimpleRoutingHandler;
5353
use Psr\Http\Message\RequestInterface;
5454
use Psr\Http\Server\RequestHandlerInterface;
@@ -70,7 +70,7 @@ $handler
7070
->route(['POST'], '/entities', $entityCreatedHandler)
7171
->route(['DELETED'], '/entities/2', $entityDeletedHandler)
7272
;
73-
$client = new Client($handler);
73+
$client = new FakeHttpClient($handler);
7474

7575
$response1 = $client->sendRequest($errorRequest); // returns error 404
7676
$response2 = $client->sendRequest($entityCreatingRequest); // returns success response 201
@@ -86,15 +86,15 @@ If you pass the `\Psr\Http\Message\ServerRequestInterface` object to client and
8686
```php
8787
<?php
8888

89-
use Webclient\Fake\Client;
89+
use Webclient\Fake\FakeHttpClient;
9090
use Psr\Http\Message\ServerRequestInterface;
9191
use Psr\Http\Server\RequestHandlerInterface;
9292

9393
/**
9494
* @var RequestHandlerInterface $handler your mock handler
9595
* @var ServerRequestInterface $request your tested request
9696
*/
97-
$client = new Client($handler);
97+
$client = new FakeHttpClient($handler);
9898

99-
$response = $client->sendRequest($request->withAttribute(Client::NO_REPLACE_ATTRIBUTE, true));
99+
$response = $client->sendRequest($request->withAttribute(FakeHttpClient::NO_REPLACE_ATTRIBUTE, true));
100100
```

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=7.0",
15+
"php": "^7.4 || ^8.0",
1616
"ext-json": "*",
1717
"psr/http-client": "^1.0",
1818
"psr/http-message": "^1.0",
1919
"psr/http-server-handler": "^1.0"
2020
},
2121
"require-dev": {
2222
"psr/http-factory": "^1.0",
23-
"guzzlehttp/psr7": "^1.7",
24-
"phpunit/phpunit": ">=6.5",
23+
"nyholm/psr7": "^1.5",
24+
"phpunit/phpunit": "^6.5 || ^7.5 || 8.5 || 9.5",
2525
"squizlabs/php_codesniffer": "^3.5"
2626
},
2727
"provide": {

phpcs.xml.dist

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
<arg name="colors"/>
99

1010
<!-- inherit rules from: -->
11-
<rule ref="PSR12">
12-
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
13-
</rule>
11+
<rule ref="PSR12"/>
1412

1513
<!-- Paths to check -->
1614
<file>src</file>

src/Exception/NetworkError.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111

1212
class NetworkError extends Exception implements NetworkExceptionInterface
1313
{
14-
15-
/**
16-
* @var RequestInterface
17-
*/
18-
private $request;
14+
private RequestInterface $request;
1915

2016
public function __construct(RequestInterface $request, Throwable $previous = null)
2117
{

src/Client.php renamed to src/FakeHttpClient.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@
1414
use Psr\Http\Server\RequestHandlerInterface;
1515
use Throwable;
1616

17-
final class Client implements ClientInterface
17+
final class FakeHttpClient implements ClientInterface
1818
{
19+
public const NO_REPLACE_ATTRIBUTE = 'webclient-fake-http-client-request-no-replace';
1920

20-
const NO_REPLACE_ATTRIBUTE = 'webclient-fake-http-client-request-no-replace';
21-
22-
/**
23-
* @var RequestHandlerInterface
24-
*/
25-
private $handler;
26-
27-
/**
28-
* @var array
29-
*/
30-
private $server;
21+
private RequestHandlerInterface $handler;
22+
private array $server;
3123

3224
public function __construct(RequestHandlerInterface $handler, array $server = [])
3325
{

src/Handler/SimpleRoutingHandler.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
class SimpleRoutingHandler implements RequestHandlerInterface
1212
{
13-
14-
/**
15-
* @var RequestHandlerInterface[]
16-
*/
17-
private $handlers = [];
13+
/** @var RequestHandlerInterface[] */
14+
private array $handlers = [];
1815

1916
public function __construct(RequestHandlerInterface $defaultHandler)
2017
{

0 commit comments

Comments
 (0)