Skip to content

Commit

Permalink
Upgrade from http-interop to psr.
Browse files Browse the repository at this point in the history
  • Loading branch information
dutekvejin committed Dec 28, 2018
1 parent aa37266 commit 71a459a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 26 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# Change Log
All notable changes to this project will be documented in this file.

## 1.0.1 - December 28, 2018

### Added

- Added support for `psr/http-factory` ^1.0
- Added support for `psr/http-server-handler` ^1.0
- Added support for `psr/http-server-middlewar` ^1.0

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Removed support for `http-interop/http-factory`
- Removed support for `http-interop/http-server-handler`
- Removed support for `http-interop/http-server-middleware`

### Fixed

- Nothing.

## 1.0.0 - November 23, 2017

### Added
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
],
"require": {
"php": "^7.0",
"http-interop/http-factory": "^0.3.0",
"http-interop/http-server-handler": "^1.0",
"http-interop/http-server-middleware": "^1.0"
"psr/http-factory": "^1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.7",
"http-interop/http-factory-diactoros": "^0.3.0",
"http-interop/http-factory-guzzle": "^0.3.1",
"http-interop/http-factory-diactoros": "^1.0",
"http-interop/http-factory-guzzle": "^1.0",
"phpunit/phpunit": "^6.4"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion examples/usage-with-diactoros.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Http\Factory\Diactoros\ResponseFactory;
use Http\Factory\Diactoros\ServerRequestFactory;
use Interop\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use WeCodeIn\Http\Server\RequestHandler;
use WeCodeIn\Http\Server\Middleware\CallableMiddleware;

Expand Down
2 changes: 1 addition & 1 deletion examples/usage-with-guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Http\Factory\Guzzle\ResponseFactory;
use Http\Factory\Guzzle\ServerRequestFactory;
use Interop\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use WeCodeIn\Http\Server\RequestHandler;
use WeCodeIn\Http\Server\Middleware\CallableMiddleware;

Expand Down
6 changes: 3 additions & 3 deletions src/Middleware/CallableMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace WeCodeIn\Http\Server\Middleware;

use Interop\Http\Server\RequestHandlerInterface;
use Interop\Http\Server\MiddlewareInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

class CallableMiddleware implements MiddlewareInterface
{
Expand All @@ -26,7 +26,7 @@ public function __construct(callable $callable)
$this->callable = $callable;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
return ($this->callable)($request, $handler);
}
Expand Down
8 changes: 4 additions & 4 deletions src/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

namespace WeCodeIn\Http\Server;

use Interop\Http\Factory\ResponseFactoryInterface;
use Interop\Http\Server\RequestHandlerInterface;
use Interop\Http\Server\MiddlewareInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

class RequestHandler implements RequestHandlerInterface
{
Expand All @@ -29,7 +29,7 @@ public function __construct(ResponseFactoryInterface $responseFactory, Middlewar
$this->middlewares = $middlewares;
}

public function handle(ServerRequestInterface $request) : ResponseInterface
public function handle(ServerRequestInterface $request): ResponseInterface
{
$handler = clone $this;

Expand Down
6 changes: 3 additions & 3 deletions tests/RequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

namespace WeCodeIn\Http\Server\Tests;

use Interop\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;
use PHPUnit_Framework_MockObject_Matcher_Invocation as Invocation;
use PHPUnit\Framework\MockObject\Matcher\Invocation;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

class RequestHandlerTest extends TestCase
{
Expand Down
18 changes: 9 additions & 9 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@

use Http\Factory\Guzzle\ResponseFactory;
use Http\Factory\Guzzle\ServerRequestFactory;
use Interop\Http\Factory\ResponseFactoryInterface;
use Interop\Http\Factory\ServerRequestFactoryInterface;
use Interop\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use WeCodeIn\Http\Server\RequestHandler;

class TestCase extends BaseTestCase
{
protected function getServerRequestFactory() : ServerRequestFactoryInterface
protected function getServerRequestFactory(): ServerRequestFactoryInterface
{
return new ServerRequestFactory();
}

protected function createServerRequest() : ServerRequestInterface
protected function createServerRequest(): ServerRequestInterface
{
return $this->getServerRequestFactory()
->createServerRequest('GET', 'http://example.com');
}

protected function getResponseFactory() : ResponseFactoryInterface
protected function getResponseFactory(): ResponseFactoryInterface
{
return new ResponseFactory();
}

protected function createResponse(int $code = 200) : ResponseInterface
protected function createResponse(int $code = 200): ResponseInterface
{
return $this->getResponseFactory()
->createResponse($code);
}

protected function createRequestHandler(MiddlewareInterface ...$middlewares) : RequestHandlerInterface
protected function createRequestHandler(MiddlewareInterface ...$middlewares): RequestHandlerInterface
{
return new RequestHandler($this->getResponseFactory(), ...$middlewares);
}
Expand Down

0 comments on commit 71a459a

Please sign in to comment.