public function testFlattenDependencies()
 {
     $astMap = $this->prophesize(AstMap::class);
     $astMap->getAstClassReferences()->willReturn([$this->getAstReference('classA'), $this->getAstReference('classB'), $this->getAstReference('classBaum'), $this->getAstReference('classWeihnachtsbaum'), $this->getAstReference('classGeschmückterWeihnachtsbaum')]);
     $dependencyResult = new DependencyResult();
     $dependencyResult->addDependency($classADep = $this->getDependency('classA'));
     $dependencyResult->addDependency($classBDep = $this->getDependency('classB'));
     $dependencyResult->addDependency($classBaumDep = $this->getDependency('classBaum'));
     $dependencyResult->addDependency($classWeihnachtsbaumsDep = $this->getDependency('classWeihnachtsbaumsA'));
     $astMap->getClassInherits('classA')->willReturn([]);
     $astMap->getClassInherits('classB')->willReturn([]);
     $astMap->getClassInherits('classBaum')->willReturn([]);
     $astMap->getClassInherits('classWeihnachtsbaum')->willReturn([AstInherit::newUses('classBaum', 3)]);
     $astMap->getClassInherits('classGeschmückterWeihnachtsbaum')->willReturn([new FlattenAstInherit(AstMap\AstInherit::newExtends('classBaum', 3), [AstInherit::newUses('classWeihnachtsbaum', 3)])]);
     (new DependencyInheritanceFlatter())->flattenDependencies($astMap->reveal(), $dependencyResult);
     $inheritDeps = array_filter($dependencyResult->getDependenciesAndInheritDependencies(), function ($v) {
         return $v instanceof InheritDependency;
     });
     $this->assertCount(1, $inheritDeps);
 }
 /**
  * @param Node\Stmt\ClassLike $klass
  * @return AstInheritInterface[]
  */
 public static function findInheritances(Node\Stmt\ClassLike $klass)
 {
     $buffer = [];
     if ($klass instanceof Class_ && $klass->namespacedName instanceof Name) {
         if ($klass->extends instanceof Name) {
             $buffer[] = AstInherit::newExtends($klass->extends->toString(), $klass->extends->getLine());
         }
         if (!empty($klass->implements)) {
             foreach ($klass->implements as $impl) {
                 if (!$impl instanceof Name) {
                     continue;
                 }
                 $buffer[] = AstInherit::newImplements($impl->toString(), $impl->getLine());
             }
         }
     }
     if ($klass instanceof Trait_ || $klass instanceof Class_) {
         foreach ($klass->stmts as $traitUses) {
             if (!$traitUses instanceof Node\Stmt\TraitUse) {
                 continue;
             }
             foreach ($traitUses->traits as $traitUsage) {
                 if (!$traitUsage instanceof FullyQualified) {
                     continue;
                 }
                 $buffer[] = AstInherit::newUses($traitUsage->toString(), $traitUsage->getLine());
             }
         }
     }
     if ($klass instanceof Interface_ && isset($klass->namespacedName) && $klass->namespacedName instanceof Name) {
         foreach ($klass->extends as $extends) {
             $buffer[] = AstInherit::newExtends($extends->toString(), $extends->getLine());
         }
     }
     return $buffer;
 }