Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merging develop to master in preparation for 3.1.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Feb 6, 2019
2 parents 5ee5b25 + 3c9337c commit 2ef1189
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 17 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@ Versions prior to 1.0 were originally released as `phly/conduit`; please visit
its [CHANGELOG](https://github.com/phly/conduit/blob/master/CHANGELOG.md) for
details.

## 3.1.0 - 2019-02-06

### Added

- [#178](https://github.com/zendframework/zend-stratigility/pull/178) adds the class `Zend\Stratigility\EmptyPipelineHandler`, which raises an
`EmptyPipelineException` when it handles an incoming request. It's primary
purpose is for use in the `MiddlewarePipe` as a fallback handler during
`handle()` operations.

### Changed

- [#178](https://github.com/zendframework/zend-stratigility/pull/178) provides some performance improvements to `MiddlewarePipe::handle()` by
having it create an instance of `EmptyPipelineHandler` to use as a fallback
handler when it calls `process()` on itself. This prevents cloning of the
pipeline in this scenario, which is used when it acts as an application
entrypoint.

- [#185](https://github.com/zendframework/zend-stratigility/pull/185) removes the "final" declaration from the `ErrorHandler` class, to allow
more easily mocking it for testing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 3.0.3 - 2019-02-06

### Added
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev",
"dev-develop": "3.1.x-dev"
"dev-master": "3.1.x-dev",
"dev-develop": "3.2.x-dev"
}
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/EmptyPipelineHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* @see https://github.com/zendframework/zend-stratigility for the canonical source repository
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-stratigility/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Zend\Stratigility;

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

final class EmptyPipelineHandler implements RequestHandlerInterface
{
/**
* @var string
*/
private $className;

public function __construct(string $className)
{
$this->className = $className;
}

public function handle(ServerRequestInterface $request) : ResponseInterface
{
throw Exception\EmptyPipelineException::forClass($this->className);
}
}
4 changes: 2 additions & 2 deletions src/Middleware/ErrorHandler.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @see https://github.com/zendframework/zend-stratigility for the canonical source repository
* @copyright Copyright (c) 2016-2018 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2016-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-stratigility/blob/master/LICENSE.md New BSD License
*/

Expand Down Expand Up @@ -68,7 +68,7 @@
* Listeners are attached using the attachListener() method, and triggered
* in the order attached.
*/
final class ErrorHandler implements MiddlewareInterface
class ErrorHandler implements MiddlewareInterface
{
/**
* @var callable[]
Expand Down
14 changes: 3 additions & 11 deletions src/MiddlewarePipe.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @see https://github.com/zendframework/zend-stratigility for the canonical source repository
* @copyright Copyright (c) 2015-2018 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2015-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-stratigility/blob/master/LICENSE.md New BSD License
*/

Expand Down Expand Up @@ -69,13 +69,7 @@ public function __clone()
*/
public function handle(ServerRequestInterface $request) : ResponseInterface
{
if ($this->pipeline->isEmpty()) {
throw Exception\EmptyPipelineException::forClass(__CLASS__);
}

$nextHandler = clone $this;
$middleware = $nextHandler->pipeline->dequeue();
return $middleware->process($request, $nextHandler);
return $this->process($request, new EmptyPipelineHandler(__CLASS__));
}

/**
Expand All @@ -86,9 +80,7 @@ public function handle(ServerRequestInterface $request) : ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{
$next = new Next($this->pipeline, $handler);

return $next->handle($request);
return (new Next($this->pipeline, $handler))->handle($request);
}

/**
Expand Down

0 comments on commit 2ef1189

Please sign in to comment.