Skip to content

Commit

Permalink
Switch to http-server-middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 11, 2017
1 parent eeb83a8 commit 5180e05
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: php
sudo: false

php:
- 5.6
- 7.0
- 7.1

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## UNRELEASED

### Removed

* Removed support for PHP 5.x.

### Changed

* Replaced `http-interop/http-middleware` with `http-interop/http-server-middleware`.

## [0.8.0] - 2017-09-21

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Middleware to use [FastRoute](https://github.com/nikic/FastRoute) for handler di

## Requirements

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

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"issues": "https://github.com/middlewares/fast-route/issues"
},
"require": {
"php": "^5.6 || ^7.0",
"http-interop/http-middleware": "^0.5",
"php": "^7.0",
"nikic/fast-route": "^1.0",
"middlewares/utils": "~0.12"
"middlewares/utils": "~0.13",
"http-interop/http-server-middleware": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.5 || ^6.0",
"phpunit/phpunit": "^6.0",
"zendframework/zend-diactoros": "^1.3",
"friendsofphp/php-cs-fixer": "^2.0",
"squizlabs/php_codesniffer": "^3.0",
Expand Down
18 changes: 4 additions & 14 deletions src/FastRoute.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);

namespace Middlewares;

Expand All @@ -23,8 +24,6 @@ class FastRoute implements MiddlewareInterface

/**
* Set the Dispatcher instance.
*
* @param Dispatcher $router
*/
public function __construct(Dispatcher $router)
{
Expand All @@ -33,12 +32,8 @@ public function __construct(Dispatcher $router)

/**
* Set the attribute name to store handler reference.
*
* @param string $attribute
*
* @return self
*/
public function attribute($attribute)
public function attribute(string $attribute): self
{
$this->attribute = $attribute;

Expand All @@ -47,13 +42,8 @@ public function attribute($attribute)

/**
* Process a server request and return a response.
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
*
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$route = $this->router->dispatch($request->getMethod(), $request->getUri()->getPath());

Expand Down Expand Up @@ -82,7 +72,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
*
* @return ServerRequestInterface
*/
protected function setHandler(ServerRequestInterface $request, $handler)
protected function setHandler(ServerRequestInterface $request, $handler): ServerRequestInterface
{
return $request->withAttribute($this->attribute, $handler);
}
Expand Down

1 comment on commit 5180e05

@shadowhand
Copy link
Member

Choose a reason for hiding this comment

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

👍

Please sign in to comment.