| | |
| | | use ReflectionClass; |
| | | use Closure; |
| | | use ReflectionNamedType; |
| | | use InvalidArgumentException; |
| | | |
| | | class Container { |
| | | |
| | |
| | | $type = $param->getType(); |
| | | |
| | | if($type === null) { |
| | | exit("Constructor parameter '{$param->getName()}' in the $class_name class has no type declaration"); |
| | | throw new InvalidArgumentException("Constructor parameter '{$param->getName()}' in the $class_name class has no type declaration"); |
| | | } |
| | | |
| | | if( ! ($type instanceof ReflectionNamedType)) { |
| | | exit("Constructor parameter '{$param->getName()}' in the $class_name class is an invalid type: $type |
| | | throw new InvalidArgumentException("Constructor parameter '{$param->getName()}' in the $class_name class is an invalid type: $type |
| | | - only single named type supported"); |
| | | } |
| | | |
| | | if($type->isBuiltin()) { |
| | | exit("Unable to resolve costructor parameter '{$param->getName()}' of type '$type' in the '$class_name' class"); |
| | | throw new InvalidArgumentException("Unable to resolve costructor parameter '{$param->getName()}' of type '$type' in the '$class_name' class"); |
| | | } |
| | | $dependencies[] = $this->get((string) $type); |
| | | } |