diff --git a/lib/Dispatcher.php b/lib/Dispatcher.php index 5f045df..6354059 100644 --- a/lib/Dispatcher.php +++ b/lib/Dispatcher.php @@ -133,7 +133,9 @@ public function dispatch($msg) // Fallback for php 7.0, which is still supported (and doesn't have nullable). $class = (string)$paramType; } - $value = $this->mapper->map($value, new $class()); + if ($class !== 'mixed') { + $value = $this->mapper->map($value, new $class()); + } } } else if (is_array($value) && isset($docBlock)) { // Get the array type from the DocBlock diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php index 8b54d06..8b223a9 100644 --- a/tests/DispatcherTest.php +++ b/tests/DispatcherTest.php @@ -57,6 +57,14 @@ public function testCallMethodWithMissingArgument() $this->assertEquals($this->calls, [new MethodCall('someMethodWithDifferentlyTypedArgs', [0 => null, 1 => 0])]); } + /*public function testCallMethodWithMixedParam() + { + $result = $this->dispatcher->dispatch((string)new Request(1, 'someMethodWithMixedTypeParam', ['arg' => new Argument('whatever')])); + $this->assertEquals('Hello World', $result); + $this->assertIsObject($this->calls[0]->args[0]); + $this->assertEquals($this->calls, [new MethodCall('someMethodWithMixedTypeParam', [0 => $this->calls[0]->args[0]])]); + }*/ + public function testCallMethodWithUnionTypeParamTag() { $result = $this->dispatcher->dispatch((string)new Request(1, 'someMethodWithUnionTypeParamTag', ['arg' => [new Argument('whatever')]])); diff --git a/tests/Target.php b/tests/Target.php index 84ece52..5ea4b6b 100644 --- a/tests/Target.php +++ b/tests/Target.php @@ -44,6 +44,12 @@ public function someMethodWithUnionTypeParamTag($arg) return 'Hello World'; } + /*public function someMethodWithMixedTypeParam(mixed $arg) + { + $this->calls[] = new MethodCall('someMethodWithMixedTypeParam', func_get_args()); + return 'Hello World'; + }*/ + public function someMethodWithDifferentlyTypedArgs(string $arg1 = null, int $arg2 = null) { $this->calls[] = new MethodCall('someMethodWithDifferentlyTypedArgs', func_get_args());