111
This commit is contained in:
+3
-33
@@ -33,7 +33,7 @@ trait Attributes
|
||||
continue;
|
||||
}
|
||||
|
||||
$instance = $this->format_annotation($attribute);
|
||||
$instance = $attribute->newInstance();
|
||||
|
||||
$this->_classTarget[$className][] = $instance;
|
||||
|
||||
@@ -120,7 +120,7 @@ trait Attributes
|
||||
if (!class_exists($attribute->getName())) {
|
||||
continue;
|
||||
}
|
||||
$instance = $this->format_annotation($attribute);
|
||||
$instance = $attribute->newInstance();
|
||||
|
||||
$this->_classMethodNote[$className][$ReflectionMethod->getName()][] = $instance;
|
||||
|
||||
@@ -166,7 +166,7 @@ trait Attributes
|
||||
continue;
|
||||
}
|
||||
|
||||
$instance = $this->format_annotation($attribute);
|
||||
$instance = $attribute->newInstance();
|
||||
|
||||
$this->_classPropertyNote[$className][$ReflectionMethod->getName()] = $instance;
|
||||
|
||||
@@ -176,36 +176,6 @@ trait Attributes
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \ReflectionAttribute $attribute
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private function format_annotation(ReflectionAttribute $attribute)
|
||||
{
|
||||
$reflection_class = new ReflectionClass($attribute->getName());
|
||||
|
||||
$argument = $attribute->getArguments();
|
||||
|
||||
$array = ['class' => $attribute->getName(), 'params' => []];
|
||||
foreach ($reflection_class->getConstructor()->getParameters() as $key => $parameter) {
|
||||
if (isset($argument[$parameter->getName()])) {
|
||||
$array['params'][$parameter->getName()] = $argument[$parameter->getName()];
|
||||
} else {
|
||||
if (!isset($argument[$key])) {
|
||||
$array['params'][$parameter->getName()] = $parameter->getDefaultValue();
|
||||
} else {
|
||||
$array['params'][$parameter->getName()] = $argument[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($reflection_class);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param string|null $class
|
||||
|
||||
@@ -203,7 +203,7 @@ class Container extends BaseObject implements ContainerInterface
|
||||
{
|
||||
foreach ($this->getPropertyNote($reflect) as $property => $inject) {
|
||||
/** @var Inject $inject */
|
||||
$inject['class']::execute((object)$inject['params'] ,$object, $property);
|
||||
$inject->execute($object, $property);
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user