1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This file is part of phpDocumentor. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @author Mike van Riel <[email protected]> |
11
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
12
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
13
|
|
|
* @link http://phpdoc.org |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace phpDocumentor\Compiler\Pass; |
17
|
|
|
|
18
|
|
|
use phpDocumentor\Compiler\CompilerPassInterface; |
19
|
|
|
use phpDocumentor\Descriptor\ClassDescriptor; |
20
|
|
|
use phpDocumentor\Descriptor\ProjectDescriptor; |
21
|
|
|
use phpDocumentor\Reflection\Fqsen; |
22
|
|
|
|
23
|
|
|
final class ClassTreeBuilder implements CompilerPassInterface |
24
|
|
|
{ |
25
|
|
|
const COMPILER_PRIORITY = 9000; |
26
|
|
|
|
27
|
|
|
public function getDescription(): string |
28
|
|
|
{ |
29
|
|
|
return 'Adding Parents to child classes'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function execute(ProjectDescriptor $project): void |
33
|
|
|
{ |
34
|
|
|
foreach ($project->getFiles() as $file) { |
35
|
|
|
/** @var ClassDescriptor $class */ |
36
|
|
|
foreach ($file->getClasses()->getAll() as $class) { |
37
|
|
|
if ($class->getParent() instanceof Fqsen) { |
38
|
|
|
$parent = $project->getIndexes()->get('classes')->get((string) $class->getParent()); |
39
|
|
|
if ($parent instanceof ClassDescriptor) { |
40
|
|
|
$class->setParent($parent); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
foreach ($class->getInterfaces()->getAll() as $interface) { |
45
|
|
|
$interfaceDescriptor = $project->getIndexes()->get('interfaces')->get((string) $interface); |
46
|
|
|
$class->getInterfaces()->set((string) $interface, $interfaceDescriptor); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|