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

Commit

Permalink
Merge branch 'feature/440' into develop
Browse files Browse the repository at this point in the history
Close #440
  • Loading branch information
weierophinney committed Feb 13, 2017
2 parents 4b26b99 + 2e172d4 commit 9b5d41f
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 43 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ All notable changes to this project will be documented in this file, in reverse

### Changes

- [#440](https://github.com/zendframework/zend-expressive/pull/440) changes the
`Zend\Expressive\Application::__call($method, array $args)` signature; in
previous versions, `$args` did not have a typehint. If you are extending the
class and overriding this method, you will need to update your signature
accordingly.

- [#428](https://github.com/zendframework/zend-expressive/pull/428) updates
`Zend\Expressive\Container\ApplicationFactory` to ignore the
`zend-expressive.raise_throwables` configuration setting; Stratigility 2.X no
Expand Down
10 changes: 10 additions & 0 deletions doc/book/reference/migration/to-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Expressive 2.0 should not result in many upgrade problems for users. However,
starting in this version, we offer a few changes affecting the following that
you should be aware of, and potentially update your application to adopt:

- [Signature changes](#signature-changes)
- [Removed functionality](#removed-functionality)
- [Deprecated functionality](#deprecated-functionality)
- [Usage of http-interop middleware](#http-interop)
Expand All @@ -13,6 +14,15 @@ you should be aware of, and potentially update your application to adopt:
- [Programmatic middleware pipelines](#programmatic-middleware-pipelines)
- [Implicit handling of `HEAD` and `OPTIONS` requests](#handling-head-and-options-requests)

## Signature changes

The following signature changes were made that could affect _class extensions_:

- `Zend\Expressive\Application::__call($method, array $args)`: previously, the
`$args` argument was not typehinted; it now is. If you are extending this
class and overriding that method, you will need to update your method
signature accordingly.

## Removed functionality

The following classes and/or methods were removed for the Expressive 2.0
Expand Down
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function __construct(
* @throws Exception\BadMethodCallException if the $method is not in $httpRouteMethods.
* @throws Exception\BadMethodCallException if receiving more or less than 2 arguments.
*/
public function __call($method, $args)
public function __call($method, array $args)
{
if (! in_array(strtoupper($method), $this->httpRouteMethods, true)) {
throw new Exception\BadMethodCallException('Unsupported method');
Expand Down
2 changes: 1 addition & 1 deletion src/IsCallableInteropMiddlewareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait IsCallableInteropMiddlewareTrait
/**
* Is callable middleware interop middleware?
*
* @param callable $middleware
* @param mixed $middleware
* @return bool
*/
private function isCallableInteropMiddleware($middleware)
Expand Down
12 changes: 6 additions & 6 deletions test/Application/ConfigInjectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ public static function assertPipelineContainsInstanceOf($class, $pipeline, $mess
public function callableMiddlewares()
{
return [
['HelloWorld'],
[
['HelloWorld'],
[
function () {
},
],
[[InvokableMiddleware::class, 'staticallyCallableMiddleware']],
],
[[InvokableMiddleware::class, 'staticallyCallableMiddleware']],
];
}

/**
* @dataProvider callableMiddlewares
*
* @param callable $middleware
* @param callable|array|string $middleware
*/
public function testInjectRoutesFromConfigSetsUpRoutesFromConfig($middleware)
{
Expand Down Expand Up @@ -519,7 +519,7 @@ public function testInjectPipelineFromConfigRaisesExceptionForSpecsOmittingMiddl
'middleware_pipeline' => [
[
'this' => 'will not work',
]
],
],
];
$app = $this->createApplication();
Expand Down
44 changes: 24 additions & 20 deletions test/Container/ApplicationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ public function testFactoryWillPullAllReplaceableDependenciesFromContainerWhenPr
public function callableMiddlewares()
{
return [
['HelloWorld'],
[
['HelloWorld'],
[
function () {
}
],
[[InvokableMiddleware::class, 'staticallyCallableMiddleware']],
},
],
[[InvokableMiddleware::class, 'staticallyCallableMiddleware']],
];
}

/**
* @dataProvider callableMiddlewares
*
* @param callable $middleware
* @param callable|array|string $middleware
*/
public function testFactorySetsUpRoutesFromConfig($middleware)
{
Expand Down Expand Up @@ -227,11 +227,11 @@ public function testCanSpecifyRouteOptionsViaConfiguration()
{
$expected = [
'values' => [
'foo' => 'bar'
'foo' => 'bar',
],
'tokens' => [
'bar' => 'foo'
]
'bar' => 'foo',
],
];
$config = [
'routes' => [
Expand All @@ -240,7 +240,7 @@ public function testCanSpecifyRouteOptionsViaConfiguration()
'middleware' => 'HelloWorld',
'name' => 'home',
'allowed_methods' => ['GET'],
'options' => $expected
'options' => $expected,
],
],
];
Expand Down Expand Up @@ -314,11 +314,13 @@ public function testWillCreatePipelineBasedOnMiddlewareConfiguration()
['path' => '/dynamic-path', 'middleware' => 'DynamicPath'],
['middleware' => $noPath],
['middleware' => 'Goodbye'],
['middleware' => [
$pipelineFirst,
'Hello',
$pipelineLast,
]],
[
'middleware' => [
$pipelineFirst,
'Hello',
$pipelineLast,
],
],
];

$config = ['middleware_pipeline' => $pipeline];
Expand Down Expand Up @@ -453,11 +455,13 @@ public function testWillNotInjectConfiguredRoutesOrPipelineIfProgrammaticPipelin
['path' => '/dynamic-path', 'middleware' => 'DynamicPath'],
['middleware' => $noPath],
['middleware' => 'Goodbye'],
['middleware' => [
$pipelineFirst,
'Hello',
$pipelineLast,
]],
[
'middleware' => [
$pipelineFirst,
'Hello',
$pipelineLast,
],
],
],
'routes' => [
[
Expand Down
10 changes: 6 additions & 4 deletions test/Container/ErrorResponseGeneratorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ public function testUsesConfiguredTemplateRenderToSetGeneratorRenderer()
public function testUsesTemplateConfigurationToSetTemplate()
{
$this->container->has('config')->willReturn(true);
$this->container->get('config')->willReturn(['zend-expressive' => [
'error_handler' => [
'template_error' => 'error::custom',
$this->container->get('config')->willReturn([
'zend-expressive' => [
'error_handler' => [
'template_error' => 'error::custom',
],
],
]]);
]);
$this->container->has(TemplateRendererInterface::class)->willReturn(false);
$factory = new ErrorResponseGeneratorFactory();

Expand Down
22 changes: 11 additions & 11 deletions test/Router/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function getApplication()
public function routerAdapters()
{
return [
'aura' => [AuraRouter::class],
'fast-route' => [FastRouteRouter::class],
'zf2' => [ZendRouter::class],
'aura' => [AuraRouter::class],
'fast-route' => [FastRouteRouter::class],
'zf2' => [ZendRouter::class],
];
}

Expand All @@ -76,7 +76,7 @@ public function routerAdapters()
*/
private function createApplicationWithGetPost($adapter, $getName = null, $postName = null)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();

$app->get('/foo', function ($req, $res, $next) {
Expand Down Expand Up @@ -104,7 +104,7 @@ private function createApplicationWithGetPost($adapter, $getName = null, $postNa
*/
private function createApplicationWithRouteGetPost($adapter, $getName = null, $postName = null)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();

$app->route('/foo', function ($req, $res, $next) {
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testRoutingWithSamePathWithRouteWithName($adapter)
*/
public function testRoutingWithSamePathWithRouteWithMultipleMethods($adapter)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();
$app->pipeDispatchMiddleware();

Expand Down Expand Up @@ -322,7 +322,7 @@ public function routerAdaptersForHttpMethods()
*/
public function testMatchWithAllHttpMethods($adapter, $method)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();
$app->pipeDispatchMiddleware();

Expand Down Expand Up @@ -382,7 +382,7 @@ public function notAllowedMethod()
*/
public function testAllowedMethodsWhenOnlyPutMethodSet($adapter, $method)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();
$app->pipe(new Middleware\ImplicitHeadMiddleware());
$app->pipe(new Middleware\ImplicitOptionsMiddleware());
Expand Down Expand Up @@ -414,7 +414,7 @@ public function testAllowedMethodsWhenOnlyPutMethodSet($adapter, $method)
*/
public function testAllowedMethodsWhenNoHttpMethodsSet($adapter, $method)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();
$app->pipe(new Middleware\ImplicitHeadMiddleware());
$app->pipe(new Middleware\ImplicitOptionsMiddleware());
Expand Down Expand Up @@ -446,7 +446,7 @@ public function testAllowedMethodsWhenNoHttpMethodsSet($adapter, $method)
*/
public function testNotAllowedMethodWhenNoHttpMethodsSet($adapter, $method)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();
$app->pipeDispatchMiddleware();

Expand Down Expand Up @@ -476,7 +476,7 @@ public function testNotAllowedMethodWhenNoHttpMethodsSet($adapter, $method)
*/
public function testWithOnlyRootPathRouteDefinedRoutingToSubPathsShouldDelegate($adapter)
{
$app = new Application(new $adapter);
$app = new Application(new $adapter());
$app->pipeRoutingMiddleware();

$app->route('/', function ($req, $res, $next) {
Expand Down

0 comments on commit 9b5d41f

Please sign in to comment.