diff --git a/lib/Dispatcher.php b/lib/Dispatcher.php index 5f045df..cb2116a 100644 --- a/lib/Dispatcher.php +++ b/lib/Dispatcher.php @@ -152,7 +152,7 @@ public function dispatch($msg) } } } else if ($type instanceof Types\Array_) { - $class = (string)$type->getValueType()->getFqsen(); + $class = (string) $type->getValueType()->getFqsen(); $value = $this->mapper->mapArray($value, [], $class); } else { throw new Error('Type is not matching @param tag', ErrorCode::INVALID_PARAMS); diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php index 8b54d06..51b3f36 100644 --- a/tests/DispatcherTest.php +++ b/tests/DispatcherTest.php @@ -63,7 +63,6 @@ public function testCallMethodWithUnionTypeParamTag() $this->assertEquals('Hello World', $result); $this->assertEquals($this->calls, [new MethodCall('someMethodWithUnionTypeParamTag', [[new Argument('whatever')]])]); } - public function testCallMethodWithTypeHintWithNamedArgsOnNestedTarget() { $result = $this->dispatcher->dispatch((string)new Request(1, 'nestedTarget->someMethodWithTypeHint', ['arg' => new Argument('whatever')])); @@ -72,5 +71,11 @@ public function testCallMethodWithTypeHintWithNamedArgsOnNestedTarget() $this->assertEquals($this->callsOfNestedTarget, [new MethodCall('someMethodWithTypeHint', [new Argument('whatever')])]); } + public function testCallMethodWithArrayTypeHintAndDocblock(): void + { + $result = $this->dispatcher->dispatch((string)new Request(1, 'someMethodWithArrayTypeHint', ['args' => [new Argument('1'), new Argument('2')]])); + $this->assertEquals('Hello World', $result); + $this->assertEquals($this->calls, [new MethodCall('someMethodWithArrayTypeHint', [[new Argument('1'), new Argument('2')]])]); + } } diff --git a/tests/Target.php b/tests/Target.php index 84ece52..e9651ce 100644 --- a/tests/Target.php +++ b/tests/Target.php @@ -49,4 +49,13 @@ public function someMethodWithDifferentlyTypedArgs(string $arg1 = null, int $arg $this->calls[] = new MethodCall('someMethodWithDifferentlyTypedArgs', func_get_args()); return 'Hello World'; } + + /** + * @param Argument[] $args + */ + public function someMethodWithArrayTypeHint(array $args): string + { + $this->calls[] = new MethodCall('someMethodWithArrayTypeHint', func_get_args()); + return 'Hello World'; + } }