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

CS fixes (v2.0) #440

Merged
merged 1 commit into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note this change. If someone override this method need to do the same on his extension, otherwise will get

Strict Standards: Declaration ...::__call should be compatible with Application::__call($method, array $args)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting case, as, technically, __call() is defined originally at the engine level, which allows the user to either include or omit the typehint for the $args (or, per the documentation, $arguments) argument.

That said, once the method is declared by a class, whatever signature it uses must be used by any extending class.

In this particular case, while we are bumping the major version, it's a bit of a WTF for upgraders if they are overriding the class to add other virtual methods. That said, it's easy enough to correct, as PHP provides the necessary information to update your own code. I'll detail it in the migration notes when merging.

{
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