Skip to content

Commit 34bfd67

Browse files
committed
Replace slim/psr7 with nyholm/psr7
1 parent 1a1a2b8 commit 34bfd67

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

composer.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "selective/validation",
3-
"description": "Validation error collector and transformer",
4-
"minimum-stability": "stable",
53
"type": "library",
4+
"description": "Validation error collector and transformer",
65
"keywords": [
76
"validation",
87
"middleware",
@@ -13,37 +12,24 @@
1312
"license": "MIT",
1413
"require": {
1514
"php": "^7.2 || ^8.0",
15+
"ext-json": "*",
1616
"psr/http-factory": "^1.0.1",
17-
"psr/http-server-middleware": "^1.0.1",
18-
"ext-json": "*"
17+
"psr/http-server-middleware": "^1.0.1"
1918
},
2019
"require-dev": {
2120
"cakephp/validation": "^4.2",
2221
"fig/http-message-util": "^1.1",
2322
"friendsofphp/php-cs-fixer": "^2.16",
23+
"nyholm/psr7": "^1.4",
2424
"overtrue/phplint": "^1.1",
2525
"phpstan/phpstan": "^0.12",
2626
"phpunit/phpunit": "^8 || ^9",
2727
"relay/relay": "^2.0",
2828
"slim/psr7": "^1",
2929
"squizlabs/php_codesniffer": "^3.5"
3030
},
31-
"scripts": {
32-
"check": [
33-
"@lint",
34-
"@cs:check",
35-
"@sniffer:check",
36-
"@phpstan",
37-
"@test:coverage"
38-
],
39-
"cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --diff-format=udiff --config=.cs.php",
40-
"cs:fix": "php-cs-fixer fix --config=.cs.php",
41-
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
42-
"phpstan": "phpstan analyse src --level=max -c phpstan.neon --no-progress --ansi",
43-
"sniffer:check": "phpcs --standard=phpcs.xml",
44-
"sniffer:fix": "phpcbf --standard=phpcs.xml",
45-
"test": "phpunit --configuration phpunit.xml --do-not-cache-result",
46-
"test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
31+
"config": {
32+
"sort-packages": true
4733
},
4834
"autoload": {
4935
"psr-4": {
@@ -55,7 +41,22 @@
5541
"Selective\\Validation\\Test\\": "tests/"
5642
}
5743
},
58-
"config": {
59-
"sort-packages": true
44+
"minimum-stability": "stable",
45+
"scripts": {
46+
"cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --diff-format=udiff --config=.cs.php",
47+
"cs:fix": "php-cs-fixer fix --config=.cs.php",
48+
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
49+
"phpstan": "phpstan analyse src --level=max -c phpstan.neon --no-progress --ansi",
50+
"sniffer:check": "phpcs --standard=phpcs.xml",
51+
"sniffer:fix": "phpcbf --standard=phpcs.xml",
52+
"test": "phpunit --configuration phpunit.xml --do-not-cache-result",
53+
"test:all": [
54+
"@lint",
55+
"@cs:check",
56+
"@sniffer:check",
57+
"@phpstan",
58+
"@test:coverage"
59+
],
60+
"test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
6061
}
6162
}

tests/Middleware/MiddlewareTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Selective\Validation\Test\Middleware;
44

5+
use Nyholm\Psr7\Factory\Psr17Factory;
56
use Psr\Http\Message\ResponseInterface;
67
use Psr\Http\Message\ServerRequestInterface;
78
use Relay\Relay;
8-
use Slim\Psr7\Factory\ServerRequestFactory;
99

1010
/**
1111
* Test.
@@ -34,6 +34,6 @@ protected function runQueue(array $queue): ResponseInterface
3434
*/
3535
protected function createRequest(): ServerRequestInterface
3636
{
37-
return (new ServerRequestFactory())->createServerRequest('GET', '/');
37+
return (new Psr17Factory())->createServerRequest('GET', '/');
3838
}
3939
}

tests/Middleware/ResponseFactoryMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Selective\Validation\Test\Middleware;
44

5+
use Nyholm\Psr7\Factory\Psr17Factory;
56
use Psr\Http\Message\ResponseInterface;
67
use Psr\Http\Message\ServerRequestInterface;
78
use Psr\Http\Server\MiddlewareInterface;
89
use Psr\Http\Server\RequestHandlerInterface;
9-
use Slim\Psr7\Factory\ResponseFactory;
1010

1111
/**
1212
* Middleware.
@@ -23,6 +23,6 @@ final class ResponseFactoryMiddleware implements MiddlewareInterface
2323
*/
2424
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
2525
{
26-
return (new ResponseFactory())->createResponse();
26+
return (new Psr17Factory())->createResponse();
2727
}
2828
}

tests/Middleware/ValidationExceptionMiddlewareTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Selective\Validation\Test\Middleware;
44

55
use Fig\Http\Message\StatusCodeInterface;
6+
use Nyholm\Psr7\Factory\Psr17Factory;
67
use PHPUnit\Framework\TestCase;
78
use Selective\Validation\Encoder\JsonEncoder;
89
use Selective\Validation\Middleware\ValidationExceptionMiddleware;
910
use Selective\Validation\Transformer\ErrorDetailsResultTransformer;
10-
use Slim\Psr7\Factory\ResponseFactory;
1111

1212
/**
1313
* Tests.
@@ -26,7 +26,7 @@ class ValidationExceptionMiddlewareTest extends TestCase
2626
public function testNoError(): void
2727
{
2828
$middleware = new ValidationExceptionMiddleware(
29-
new ResponseFactory(),
29+
new Psr17Factory(),
3030
new ErrorDetailsResultTransformer(),
3131
new JsonEncoder()
3232
);
@@ -47,7 +47,7 @@ public function testNoError(): void
4747
public function testWithError(): void
4848
{
4949
$middleware = new ValidationExceptionMiddleware(
50-
new ResponseFactory(),
50+
new Psr17Factory(),
5151
new ErrorDetailsResultTransformer(),
5252
new JsonEncoder()
5353
);
@@ -82,7 +82,7 @@ public function testWithError(): void
8282
public function testWithCustomStatusCode(): void
8383
{
8484
$middleware = new ValidationExceptionMiddleware(
85-
new ResponseFactory(),
85+
new Psr17Factory(),
8686
new ErrorDetailsResultTransformer(),
8787
new JsonEncoder()
8888
);

0 commit comments

Comments
 (0)