Skip to content
Open
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 lib/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion tests/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]));
Expand All @@ -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')]])]);
}

}
9 changes: 9 additions & 0 deletions tests/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}