Skip to content

Commit 02b979e

Browse files
committed
psr-17
1 parent 69fa9ff commit 02b979e

File tree

7 files changed

+18
-8
lines changed

7 files changed

+18
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ vendor
22
composer.lock
33
.php_cs.cache
44
coverage
5+
.phpunit.result.cache

.php_cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ return PhpCsFixer\Config::create()
104104
'pre_increment' => true,
105105
'protected_to_private' => true,
106106
'return_type_declaration' => true,
107-
'self_accessor' => true,
108107
'semicolon_after_instruction' => true,
109108
'short_scalar_cast' => true,
110109
'single_blank_line_at_eof' => true,

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [1.1.0] - UNRELEASED
9+
10+
### Added
11+
12+
- PSR-17 support
13+
- New option `responseFactory`
14+
815
## [1.0.0] - 2018-01-24
916

1017
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Middleware to normalize the trailing slash of the uri path. By default removes t
1212
## Requirements
1313

1414
* PHP >= 7.0
15-
* A [PSR-7](https://packagist.org/providers/psr/http-message-implementation) http message implementation ([Diactoros](https://github.com/zendframework/zend-diactoros), [Guzzle](https://github.com/guzzle/psr7), [Slim](https://github.com/slimphp/Slim), etc...)
15+
* A [PSR-7 http library](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations)
1616
* A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)
1717

1818
## Installation

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
},
1919
"require": {
2020
"php": "^7.0",
21-
"middlewares/utils": "^1.0",
21+
"middlewares/utils": "^2.1",
2222
"psr/http-server-middleware": "^1.0"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^6.0",
25+
"phpunit/phpunit": "^6.0|^7.0",
2626
"zendframework/zend-diactoros": "^1.3",
2727
"friendsofphp/php-cs-fixer": "^2.0",
2828
"squizlabs/php_codesniffer": "^3.0"

src/TrailingSlash.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44
namespace Middlewares;
55

6+
use Middlewares\Utils\Traits\HasResponseFactory;
67
use Psr\Http\Message\ResponseInterface;
78
use Psr\Http\Message\ServerRequestInterface;
89
use Psr\Http\Server\MiddlewareInterface;
910
use Psr\Http\Server\RequestHandlerInterface;
1011

1112
class TrailingSlash implements MiddlewareInterface
1213
{
14+
use HasResponseFactory;
15+
1316
/**
1417
* @var bool Add or remove the slash
1518
*/
@@ -47,7 +50,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4750
$path = $this->normalize($uri->getPath());
4851

4952
if ($this->redirect && ($uri->getPath() !== $path)) {
50-
return Utils\Factory::createResponse(301)
53+
return $this->createResponse(301)
5154
->withHeader('Location', (string) $uri->withPath($path));
5255
}
5356

tests/TrailingSlashTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function removeProvider(): array
2525
*/
2626
public function testRemove(string $uri, string $result)
2727
{
28-
$request = Factory::createServerRequest([], 'GET', $uri);
28+
$request = Factory::createServerRequest('GET', $uri);
2929

3030
$response = Dispatcher::run([
3131
new TrailingSlash(),
@@ -55,7 +55,7 @@ public function addProvider(): array
5555
*/
5656
public function testAdd(string $uri, string $result)
5757
{
58-
$request = Factory::createServerRequest([], 'GET', $uri);
58+
$request = Factory::createServerRequest('GET', $uri);
5959

6060
$response = Dispatcher::run([
6161
new TrailingSlash(true),
@@ -70,7 +70,7 @@ function ($request, $next) {
7070

7171
public function testRedirect()
7272
{
73-
$request = Factory::createServerRequest([], 'GET', '/foo/bar/');
73+
$request = Factory::createServerRequest('GET', '/foo/bar/');
7474

7575
$response = Dispatcher::run([
7676
(new TrailingSlash())->redirect(),

0 commit comments

Comments
 (0)