File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1010use phpDocumentor \Reflection \Types ;
1111use ReflectionException ;
1212use ReflectionMethod ;
13+ use ReflectionNamedType ;
1314
1415class Dispatcher
1516{
@@ -124,7 +125,15 @@ public function dispatch($msg)
124125 // Does the parameter have a type hint?
125126 $ param = $ parameters [$ position ];
126127 if ($ param ->hasType ()) {
127- $ class = (string )$ param ->getType ();
128+ $ paramType = $ param ->getType ();
129+ if ($ paramType instanceof ReflectionNamedType) {
130+ // We have object data to map and want the class name.
131+ // This should not include the `?` if the type was nullable.
132+ $ class = $ paramType ->getName ();
133+ } else {
134+ // Fallback for php 7.0, which is still supported (and doesn't have nullable).
135+ $ class = (string )$ paramType ;
136+ }
128137 $ value = $ this ->mapper ->map ($ value , new $ class ());
129138 }
130139 } else if (is_array ($ value ) && isset ($ docBlock )) {
You can’t perform that action at this time.
0 commit comments