This commit is contained in:
as2252258@163.com
2021-07-27 04:21:09 +08:00
parent 4183ded30c
commit c22eba6217
+6 -12
View File
@@ -239,19 +239,13 @@ class Container extends BaseObject
if ($method->isStatic()) { if ($method->isStatic()) {
continue; continue;
} }
static::$_reflectionMethod[$class->getName()][$method->getName()] = $method; $this->setReflectionMethod($class, $method);
static::$_methodsAttributes[$class->getName()][$method->getName()] = [];
foreach ($method->getAttributes() as $attribute) { foreach ($method->getAttributes() as $attribute) {
if (!class_exists($attribute->getName())) { if (!class_exists($attribute->getName())) {
continue; continue;
} }
$this->setMethodsAttributes($class, $method, $attribute->newInstance());
$instance = $attribute->newInstance();
$this->setAttributeMapping($attribute, $class, $method, $instance);
$this->setMethodsAttributes($class, $method, $instance);
static::$_methodsAttributes[$class->getName()][$method->getName()][] = $attribute->newInstance();
} }
} }
} }
@@ -262,12 +256,12 @@ class Container extends BaseObject
* @param \ReflectionClass $class * @param \ReflectionClass $class
* @param $object * @param $object
*/ */
private function setAttributeMapping(\ReflectionAttribute $attribute, ReflectionClass $class, $object) private function setReflectionMethod(ReflectionClass $class, \ReflectionMethod $method)
{ {
if (!isset(static::$_attributeMaping[$attribute->getName()])) { if (!isset(static::$_attributeMaping[$class->getName()])) {
static::$_attributeMaping[$attribute->getName()] = []; static::$_attributeMaping[$class->getName()] = [];
} }
static::$_attributeMaping[$attribute->getName()][$class->getName()][] = $object; static::$_attributeMaping[$class->getName()][$method->getName()][] = $method;
} }