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

Commit a9d628b

Browse files
committed
Fixes issue with usage of duck-typed interop middleware
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.
1 parent eab9ab2 commit a9d628b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/MarshalMiddlewareTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ private function marshalInvokableMiddleware($middleware, ResponseInterface $resp
148148
return $instance;
149149
}
150150

151+
if ($this->isCallableInteropMiddleware($instance)) {
152+
return new CallableInteropMiddlewareWrapper($instance);
153+
}
154+
151155
if (! is_callable($instance)) {
152156
throw new Exception\InvalidMiddlewareException(sprintf(
153157
'Middleware of class "%s" is invalid; neither invokable nor %s',

test/Application/MarshalMiddlewareTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public function testPreparingInvokableInteropMiddlewareReturnsDecoratedInteropMi
256256

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

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

0 commit comments

Comments
 (0)