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

Commit 02f351c

Browse files
committed
Merge branch 'feature/deprecations'
Close #429
2 parents f0d7feb + 92ad9c7 commit 02f351c

11 files changed

+140
-10
lines changed

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,58 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 1.1.0 - TBD
6+
7+
### Added
8+
9+
- [#429](https://github.com/zendframework/zend-expressive/pull/429) adds
10+
`Zend\Expressive\Application::getDefaultDelegate()` as a
11+
forwards-compatibility measure for the upcoming version 2.0.0. Currently,
12+
it proxies to `getFinalHandler()`.
13+
14+
### Changed
15+
16+
- [#429](https://github.com/zendframework/zend-expressive/pull/429) updates the
17+
minimum supported zend-stratigility version to 1.3.3.
18+
19+
### Deprecated
20+
21+
- [#429](https://github.com/zendframework/zend-expressive/pull/429) deprecates
22+
the following methods and classes:
23+
- `Zend\Expressive\Application::pipeErrorHandler()`; use the
24+
`raise_throwables` flag and standard middleware to handle errors instead.
25+
- `Zend\Expressive\Application::routeMiddleware()`; this is extracted to a
26+
dedicated middleware class for 2.0.
27+
- `Zend\Expressive\Application::dispatchMiddleware()`; this is extracted to a
28+
dedicated middleware class for 2.0.
29+
- `Zend\Expressive\Application::getFinalHandler()` (this patch provides `getDefaultDelegate()` as a forwards-compatibility measure)
30+
- `Zend\Expressive\Container\Exception\InvalidArgumentException`; this will be removed
31+
in 2.0.0, and places where it was used will instead throw
32+
`Zend\Expressive\Exception\InvalidArgumentException`.
33+
- `Zend\Expressive\Container\Exception\NotFoundException`; this exception is
34+
never thrown at this point.
35+
- `Zend\Expressive\Container\TemplatedErrorHandlerFactory`
36+
- `Zend\Expressive\Container\WhoopsErrorHandlerFactory`
37+
- `Zend\Expressive\ErrorMiddlewarePipe`; Stratigility 1.3 deprecates its
38+
`Zend\Stratigility\ErrorMiddlewareInterface`, and removes it in version 2.0.
39+
use the `raise_throwables` flag and standard middleware to handle errors
40+
instead.
41+
- `Zend\Expressive\TemplatedErrorHandler`; the "final handler" concept is
42+
retired in Expressive 2.0, and replaced with default delegates (classes
43+
implementing `Interop\Http\ServerMiddleware\DelegateInterface` that will be
44+
executed when the internal pipeline is exhausted, in order to guarantee a
45+
response). If you are using custom final handlers, you will need to rewrite
46+
them when adopting Expressive 2.0.
47+
- `Zend\Expressive\WhoopsErrorHandler`
48+
49+
### Removed
50+
51+
- Nothing.
52+
53+
### Fixed
54+
55+
- Nothing.
56+
557
## 1.0.6 - 2017-01-09
658

759
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"zendframework/zend-diactoros": "^1.1",
2323
"zendframework/zend-expressive-router": "^1.1",
2424
"zendframework/zend-expressive-template": "^1.0.1",
25-
"zendframework/zend-stratigility": ">=1.1.0 < 1.3.0 || >=1.3.1 <2.0.0"
25+
"zendframework/zend-stratigility": "^1.3.3"
2626
},
2727
"require-dev": {
2828
"filp/whoops": "^1.1 || ^2.0",

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Application.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ public function pipe($path, $middleware = null)
335335
* Once middleware detection and wrapping (if necessary) is complete,
336336
* proxies to pipe().
337337
*
338+
* @deprecated since 1.1.0; to remove in 2.0.0. Stratigility v1-style
339+
* "error middleware" (middleware with four arguments, the first of which
340+
* being an error) was deprecated in Stratigility 1.3, and support
341+
* removed in Stratigility 2.0. You can start using standard middleware
342+
* for error handling by calling `raiseThrowables()` on the `Application`
343+
* instance, and piping such middleware in an outer layer of your application.
344+
* For an example, {@see Zend\Stratigility\Middleware\ErrorHandler}.
338345
* @param string|callable $path Either a URI path prefix, or middleware.
339346
* @param null|string|callable $middleware Middleware
340347
* @return self
@@ -410,6 +417,11 @@ public function pipeRouteResultObserverMiddleware()
410417
* Allow header, and `$next()` is called with its `$error` argument set
411418
* to the value `405` (invoking the next error middleware).
412419
*
420+
* @deprecated since 1.1.0; to remove in 2.0.0. This method is extracted to
421+
* its own dedicated middleware class starting in 2.0.0. If you are
422+
* manually piping this method into your application or middleware
423+
* pipelines, or overriding the method, you will need to update your
424+
* code when migrating to 2.0.
413425
* @param ServerRequestInterface $request
414426
* @param ResponseInterface $response
415427
* @param callable $next
@@ -453,6 +465,11 @@ public function routeMiddleware(ServerRequestInterface $request, ResponseInterfa
453465
* Finally, it attempts to marshal the middleware, and dispatches it when
454466
* complete, return the response.
455467
*
468+
* @deprecated since 1.1.0; to remove in 2.0.0. This method is extracted to
469+
* its own dedicated middleware class starting in 2.0.0. If you are
470+
* manually piping this method into your application or middleware
471+
* pipelines, or overriding the method, you will need to update your
472+
* code when migrating to 2.0.
456473
* @param ServerRequestInterface $request
457474
* @param ResponseInterface $response
458475
* @param callable $next
@@ -598,6 +615,9 @@ public function getContainer()
598615
/**
599616
* Return the final handler to use during `run()` if the stack is exhausted.
600617
*
618+
* @deprecated since 1.1.0; renamed to `getDefaultDelegate()` in version
619+
* 2.0.0. If you are consuming this method, please update your code to call
620+
* getDefaultDelegate() instead.
601621
* @param null|ResponseInterface $response Response instance with which to seed the
602622
* FinalHandler; used to determine if the response passed to the handler
603623
* represents the original or final response state.
@@ -618,6 +638,20 @@ public function getFinalHandler(ResponseInterface $response = null)
618638
return $this->finalHandler;
619639
}
620640

641+
/**
642+
* Return the default delegate to use during `run()` when the stack is exhausted.
643+
*
644+
* Provided as a forwards compatibility measure with version 2, and proxies
645+
* to getFinalHandler(); please note that it does not accept any arguments,
646+
* nor pass them on to that method.
647+
*
648+
* @return callable|null
649+
*/
650+
public function getDefaultDelegate()
651+
{
652+
return $this->getFinalHandler();
653+
}
654+
621655
/**
622656
* Retrieve an emitter to use during run().
623657
*

src/Container/Exception/InvalidArgumentException.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
use Interop\Container\Exception\ContainerException;
1111

12+
/**
13+
* @deprecated since 1.1.0; to remove in 2.0.0. This exception is currently
14+
* thrown by `Zend\Expressive\Container\ApplicationFactory`; starting
15+
* in 2.0.0, that factory will instead throw
16+
* `Zend\Expressive\Exception\InvalidArgumentException`.
17+
*/
1218
class InvalidArgumentException extends \InvalidArgumentException implements
1319
ContainerException,
1420
ExceptionInterface

src/Container/Exception/NotFoundException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
/**
1414
* Exception indicating a service was not found in the container.
15+
*
16+
* @deprecated since 1.1.0; to remove in 2.0.0. This exception is not thrown
17+
* by any classes within Expressive at this time.
1518
*/
1619
class NotFoundException extends RuntimeException implements
1720
ExceptionInterface,

src/Container/TemplatedErrorHandlerFactory.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
* </code>
3939
*
4040
* If any of the keys are missing, default values will be used.
41+
*
42+
* @deprecated since 1.1.0, to be removed in 2.0.0. The "final handler" concept
43+
* will be replaced with a "default delegate", which will be an
44+
* implementation of Interop\Http\ServerMiddleware\DelegateInterface that
45+
* returns a canned response. Expressive will provide tools to migrate your
46+
* code to use default delegates for 2.0; you will only need to manually
47+
* change your code if you are extending this class.
4148
*/
4249
class TemplatedErrorHandlerFactory
4350
{

src/Container/WhoopsErrorHandlerFactory.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@
6060
* </code>
6161
*
6262
* All values are booleans; omission of any implies boolean false.
63+
*
64+
* @deprecated since 1.1.0, to be removed in 2.0.0. The "final handler" concept
65+
* will be replaced with a "default delegate", which will be an
66+
* implementation of Interop\Http\ServerMiddleware\DelegateInterface that
67+
* returns a canned response. Expressive will provide tools to migrate your
68+
* code to use default delegates for 2.0; you will only need to manually
69+
* change your code if you are extending this class.
6370
*/
6471
class WhoopsErrorHandlerFactory
6572
{

src/ErrorMiddlewarePipe.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
* It is not implemented as an extension of MiddlewarePipe, as that class
2929
* implements the MiddlewareInterface, which prevents its use as error
3030
* middleware.
31+
*
32+
* @deprecated since 1.1.0; to remove in 2.0.0. Stratigility 1.3 deprecates the
33+
* concept of "error middleware" (middleware accepting exactly four arguments
34+
* the first of which being an error) in favor of using standard middleware
35+
* for error handling; you can use `Zend\Stratigility\ErrorHandler` either
36+
* directly or as an example of how to implement such middleware. If you are
37+
* using Stratigility 1.3, you can enable such error handling by calling
38+
* `raiseThrowables()` on your `Application` instance.
3139
*/
3240
class ErrorMiddlewarePipe
3341
{

src/TemplatedErrorHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
* Provides the optional ability to render a template for each of 404 and
1919
* general error conditions. If no template renderer is provided, returns
2020
* empty responses with appropriate status codes.
21+
*
22+
* @deprecated since 1.1.0, to be removed in 2.0.0. The "final handler" concept
23+
* will be replaced with a "default delegate", which will be an
24+
* implementation of Interop\Http\ServerMiddleware\DelegateInterface that
25+
* returns a canned response. Expressive will provide tools to migrate your
26+
* code to use default delegates for 2.0; you will only need to manually
27+
* change your code if you are extending this class.
2128
*/
2229
class TemplatedErrorHandler
2330
{

0 commit comments

Comments
 (0)