/**
  * @return array {[ declaringClassName => ReflectionMethodMagic[] ]}
  */
 public function getInheritedMagicMethods()
 {
     $methods = [];
     $allMethods = array_flip(array_map(function (ReflectionMethod $method) {
         return $method->getName();
     }, $this->getOwnMagicMethods()));
     /** @var ReflectionClass[] $parentClassesAndInterfaces */
     $parentClassesAndInterfaces = array_merge($this->reflectionClass->getParentClasses(), $this->reflectionClass->getInterfaces());
     foreach ($parentClassesAndInterfaces as $class) {
         $inheritedMethods = $this->getUsedElements($class->getOwnMagicMethods(), $allMethods);
         $methods = $this->sortElements($inheritedMethods, $methods, $class);
     }
     return $methods;
 }
 /**
  * @return ReflectionClass[]|array
  */
 private function getParentClassesAndInterfaces()
 {
     return array_merge($this->reflectionClass->getParentClasses(), $this->reflectionClass->getInterfaces());
 }