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

Commit 52e451f

Browse files
committed
Incorporated feedback from @webimpress
Incorporated feedback from @webimpress, with the exception of updating HTTP method names and status codes to use fig/http-message-util constants; these are already updated on the develop branch, and changing them in tests has no effect on the library code.
1 parent fba7a9b commit 52e451f

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

src/Container/ApplicationFactory.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ public function __invoke(ContainerInterface $container)
161161
? $container->get(RouterInterface::class)
162162
: new FastRouteRouter();
163163

164-
$finalHandler = (isset($config['zend-expressive']['raise_throwables'])
165-
&& $config['zend-expressive']['raise_throwables'])
164+
$finalHandler = ! empty($config['zend-expressive']['raise_throwables'])
166165
? $this->marshalNoopFinalHandler($container)
167166
: $this->marshalLegacyFinalHandler($container, $config);
168167

@@ -172,15 +171,11 @@ public function __invoke(ContainerInterface $container)
172171

173172
$app = new Application($router, $container, $finalHandler, $emitter);
174173

175-
if (isset($config['zend-expressive']['raise_throwables'])
176-
&& $config['zend-expressive']['raise_throwables']
177-
) {
174+
if (! empty($config['zend-expressive']['raise_throwables'])) {
178175
$app->raiseThrowables();
179176
}
180177

181-
if (! isset($config['zend-expressive']['programmatic_pipeline'])
182-
|| ! $config['zend-expressive']['programmatic_pipeline']
183-
) {
178+
if (empty($config['zend-expressive']['programmatic_pipeline'])) {
184179
$this->injectRoutesAndPipeline($app, $config);
185180
}
186181

test/ApplicationMarshalMiddlewarePipeTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
4-
* @copyright Copyright (c) 2016-2016 Zend Technologies USA Inc. (http://www.zend.com)
4+
* @copyright Copyright (c) 2016-2017 Zend Technologies USA Inc. (http://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
66
*/
77

88
namespace ZendTest\Expressive;
99

10+
use Exception;
1011
use PHPUnit_Framework_TestCase as TestCase;
1112
use Prophecy\Argument;
1213
use Psr\Http\Message\ResponseInterface;
1314
use RuntimeException;
15+
use Throwable;
1416
use Zend\Diactoros\Response\EmitterInterface;
1517
use Zend\Diactoros\Response;
1618
use Zend\Diactoros\ServerRequest;
@@ -61,9 +63,9 @@ public function createErrorHandler($expected)
6163
try {
6264
$response = $next($request, $response);
6365
return $response;
64-
} catch (\Throwable $e) {
66+
} catch (Throwable $e) {
6567
// fall-through
66-
} catch (\Exception $e) {
68+
} catch (Exception $e) {
6769
// fall-through
6870
}
6971

test/ApplicationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ public function invalidRequestExceptions()
644644
* @runInSeparateProcess
645645
* @preserveGlobalState disabled
646646
* @dataProvider invalidRequestExceptions
647+
* @param string $expectedException
648+
* @param string $message
647649
*/
648650
public function testRunInvokesFinalHandlerWhenServerRequestFactoryRaisesException(
649651
$expectedException,

test/Container/ApplicationFactoryTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,8 @@ public function testProperlyRegistersNestedErrorMiddlewareAsLazyErrorMiddleware(
920920
*/
921921
public function testWillNotInjectConfiguredRoutesOrPipelineIfProgrammaticPipelineFlagEnabled()
922922
{
923-
// @codingStandardsIgnoreStart
924-
$api = function ($request, $response, $next) {};
925-
// @codingStandardsIgnoreEnd
923+
$api = function ($request, $response, $next) {
924+
};
926925

927926
$dynamicPath = clone $api;
928927
$noPath = clone $api;
@@ -933,8 +932,8 @@ public function testWillNotInjectConfiguredRoutesOrPipelineIfProgrammaticPipelin
933932

934933
$config = [
935934
'middleware_pipeline' => [
936-
[ 'path' => '/api', 'middleware' => $api ],
937-
[ 'path' => '/dynamic-path', 'middleware' => 'DynamicPath' ],
935+
['path' => '/api', 'middleware' => $api],
936+
['path' => '/dynamic-path', 'middleware' => 'DynamicPath'],
938937
['middleware' => $noPath],
939938
['middleware' => 'Goodbye'],
940939
['middleware' => [

0 commit comments

Comments
 (0)