/** * @return Reflection_Property */ public function getParent() { if (!isset($this->parent)) { $this->parent = false; $parent = $this->class->getParentClass(); if ($parent) { $properties = $parent->getProperties(); if (!isset($properties[$this->name])) { $properties = $parent->getProperties([T_USE]); if (!isset($properties[$this->name])) { $properties = $parent->getProperties([T_EXTENDS]); } } if (isset($properties[$this->name])) { $this->parent = $properties[$this->name]; } } } return $this->parent ?: null; }
/** * Scan weaver for all parent AOP aspects on abstract methods * - for each methods implemented in the class or its traits * - for each parent abstract method of these methods * - for all the parent chain between the method and its parent * - if any advice : add it for the current class * * @param $methods array [$method][$index] = [$type, callback $advice] * @param $class Reflection_Class * @param $only_method string Internal use only : the method name we are up-scanning */ private function scanForAbstract(&$methods, Reflection_Class $class, $only_method = null) { if ($class->getParentName()) { $parent_class = $class->getParentClass(); $parent_methods = $parent_class->getMethods([T_EXTENDS, T_IMPLEMENTS]); foreach ($class->getMethods($only_method ? [T_EXTENDS, T_IMPLEMENTS] : [T_USE]) as $method) { if (!$only_method || $only_method === $method->name) { if (isset($parent_methods[$method->name]) && $parent_methods[$method->name]->isAbstract()) { $this->scanForAbstract($methods, $parent_class, $method->name); $joinpoints = $this->weaver->getJoinpoint([$parent_class->name, $method->name]); foreach ($joinpoints as $pointcut) { $methods[$method->name][] = $pointcut; } } } } } }