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

Commit

Permalink
Fixes issue with usage of duck-typed interop middleware
Browse files Browse the repository at this point in the history
Adds logic to `MarshalMiddlewareTrait::marshalInvokableMiddleware()` to
wrap callable interop middleware in a `CallableInteropMiddlewareWrapper`
instead of a `CallableMiddlewareWrapper`. Doing so highlighted a
problematic test in `MarshalMiddlewareTraitTest` as well, which has now
been corrected.
  • Loading branch information
weierophinney committed Mar 13, 2017
1 parent eab9ab2 commit a9d628b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/MarshalMiddlewareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ private function marshalInvokableMiddleware($middleware, ResponseInterface $resp
return $instance;
}

if ($this->isCallableInteropMiddleware($instance)) {
return new CallableInteropMiddlewareWrapper($instance);
}

if (! is_callable($instance)) {
throw new Exception\InvalidMiddlewareException(sprintf(
'Middleware of class "%s" is invalid; neither invokable nor %s',
Expand Down
2 changes: 1 addition & 1 deletion test/Application/MarshalMiddlewareTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function testPreparingInvokableInteropMiddlewareReturnsDecoratedInteropMi

$middleware = $this->prepareMiddleware($base);

$this->assertInstanceOf(CallableMiddlewareWrapper::class, $middleware);
$this->assertInstanceOf(CallableInteropMiddlewareWrapper::class, $middleware);
$this->assertAttributeInstanceOf(TestAsset\CallableInteropMiddleware::class, 'middleware', $middleware);
}

Expand Down

0 comments on commit a9d628b

Please sign in to comment.