eee
This commit is contained in:
@@ -174,6 +174,32 @@ class Container implements ContainerInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $reflect
|
||||
* @param array $construct
|
||||
* @param array $config
|
||||
* @return object|null
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function makeReflection(ReflectionClass $reflect, array $construct = [], array $config = []): ?object
|
||||
{
|
||||
if (isset($this->_singletons[$reflect->getName()])) {
|
||||
return $this->_singletons[$reflect->getName()];
|
||||
}
|
||||
|
||||
if (!$reflect->isInstantiable()) {
|
||||
throw new ReflectionException('Class ' . $reflect->getName() . ' cannot be instantiated');
|
||||
}
|
||||
|
||||
if (($handler = $reflect->getConstructor()) !== null) {
|
||||
$construct = $this->getMethodParams($handler);
|
||||
}
|
||||
$newInstance = $reflect->newInstanceArgs($construct);
|
||||
|
||||
return $this->runInit($reflect, static::configure($newInstance, $config));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $reflect
|
||||
* @param object $object
|
||||
|
||||
+2
-5
@@ -93,7 +93,7 @@ class Scanner extends Component
|
||||
if (class_exists($class)) {
|
||||
$reflect = $this->container->getReflectionClass($class);
|
||||
if ($reflect->isInstantiable()) {
|
||||
if ($reflect->isTrait() || $reflect->isEnum()) {
|
||||
if ($reflect->isTrait() || $reflect->isEnum() || $reflect->isInterface()) {
|
||||
return;
|
||||
}
|
||||
$attributes = $this->skipNames($reflect);
|
||||
@@ -105,14 +105,11 @@ class Scanner extends Component
|
||||
continue;
|
||||
}
|
||||
$attributes = $method->getAttributes();
|
||||
if (count($attributes) > 0) {
|
||||
$object = $this->container->parse($class);
|
||||
}
|
||||
foreach ($attributes as $attribute) {
|
||||
if (!class_exists($attribute->getName())) {
|
||||
continue;
|
||||
}
|
||||
$attribute->newInstance()->dispatch($object, $method->getName());
|
||||
$attribute->newInstance()->dispatch($reflect, $method->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user