| @@ -196,9 +196,15 @@ | ||
| 196 | 196 | // If the factory is not a Closure, it means it is just a class name which is |
| 197 | 197 | // bound into this container to the abstract type and we will just wrap it |
| 198 | 198 | // up inside its own Closure to give us more convenience when extending. |
| 199 | 199 | if ( ! $concrete instanceof Closure) { |
| 200 | - $concrete = $this->getClosure($abstract, $concrete); | |
| 200 | + if (is_string($concrete) && ($abstract === $concrete || class_exists($concrete) || interface_exists($concrete))) { | |
| 201 | + $concrete = $this->getClosure($abstract, $concrete); | |
| 202 | + } else { | |
| 203 | + $concrete = function () use ($concrete) { | |
| 204 | + return $concrete; | |
| 205 | + }; | |
| 206 | + } | |
| 201 | 207 | } |
| 202 | 208 | |
| 203 | 209 | $this->bindings[$abstract] = compact('concrete', 'shared'); |
| 204 | 210 | |
| @@ -996,9 +1002,15 @@ | ||
| 996 | 1002 | |
| 997 | 1003 | return $class ? $class->name : null; |
| 998 | 1004 | } |
| 999 | 1005 | |
| 1000 | - return $parameter->hasType() ? $parameter->getType()->getName() : null; | |
| 1006 | + $type = $parameter->getType(); | |
| 1007 | + | |
| 1008 | + if (! $type instanceof \ReflectionNamedType || $type->isBuiltin()) { | |
| 1009 | + return null; | |
| 1010 | + } | |
| 1011 | + | |
| 1012 | + return $type->getName(); | |
| 1001 | 1013 | } |
| 1002 | 1014 | |
| 1003 | 1015 | /** |
| 1004 | 1016 | * Get the container's bindings. |