corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-23 85f6ec1bc8f094e769835e9836b9fab7fb9e6ace
src/Framework/Container.php
@@ -4,7 +4,7 @@
use ReflectionClass;
use Closure;
use ReflectionNamedType;
use Exception;
use InvalidArgumentException;
class Container {
@@ -30,16 +30,16 @@
            $type = $param->getType();
            
            if($type === null) {
                throw new Exception("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)) {
                throw new Exception("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()) {
                throw new Exception("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);
        }