变更
This commit is contained in:
+5
-7
@@ -132,19 +132,16 @@ class Container implements ContainerInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* @return ReflectionClass|null
|
* @return ReflectionClass
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function getReflectionClass(string $className): ?ReflectionClass
|
public function getReflectionClass(string $className): ReflectionClass
|
||||||
{
|
{
|
||||||
if (isset($this->_reflection[$className])) {
|
if (isset($this->_reflection[$className])) {
|
||||||
return $this->_reflection[$className];
|
return $this->_reflection[$className];
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = new ReflectionClass($className);
|
$class = new ReflectionClass($className);
|
||||||
if (!$class->isInstantiable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_reflection[$className] = $class;
|
return $this->_reflection[$className] = $class;
|
||||||
}
|
}
|
||||||
@@ -159,8 +156,9 @@ class Container implements ContainerInterface
|
|||||||
*/
|
*/
|
||||||
public function make(string $className, array $construct = [], array $config = []): ?object
|
public function make(string $className, array $construct = [], array $config = []): ?object
|
||||||
{
|
{
|
||||||
if (($reflect = $this->getReflectionClass($className)) === null) {
|
$reflect = $this->getReflectionClass($className);
|
||||||
return null;
|
if (!$reflect->isInstantiable()) {
|
||||||
|
throw new ReflectionException('Class ' . $className . ' cannot be instantiated');
|
||||||
}
|
}
|
||||||
|
|
||||||
$constructorHandler = $reflect->getConstructor();
|
$constructorHandler = $reflect->getConstructor();
|
||||||
|
|||||||
Reference in New Issue
Block a user