|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2017 Julius Härtl <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Julius Härtl <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace JuliusHaertl\PHPDocToRst\Extension; |
|
25
|
|
|
|
|
26
|
|
|
use JuliusHaertl\PHPDocToRst\Builder\ExtensionBuilder; |
|
27
|
|
|
use JuliusHaertl\PHPDocToRst\Builder\FileBuilder; |
|
28
|
|
|
use JuliusHaertl\PHPDocToRst\Builder\InterfaceFileBuilder; |
|
29
|
|
|
use JuliusHaertl\PHPDocToRst\Builder\PhpDomainBuilder; |
|
30
|
|
|
use JuliusHaertl\PHPDocToRst\Builder\RstBuilder; |
|
31
|
|
|
use phpDocumentor\Reflection\Php\Interface_; |
|
32
|
|
|
use PhpParser\Builder\Class_; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Class InterfaceImplementors |
|
36
|
|
|
* @package JuliusHaertl\PHPDocToRst\Extension |
|
37
|
|
|
* |
|
38
|
|
|
* This extension parses all classes and interface relations. |
|
39
|
|
|
* A link to all classes implementing a specific interface |
|
40
|
|
|
* is added to the interface documentation. |
|
41
|
|
|
*/ |
|
42
|
|
|
|
|
43
|
|
|
class InterfaceImplementors extends Extension { |
|
44
|
|
|
|
|
45
|
|
|
private $implementors = []; |
|
46
|
|
|
|
|
47
|
|
|
public function prepare() { |
|
48
|
|
|
foreach ($this->project->getFiles() as $file) { |
|
49
|
|
|
foreach ($file->getClasses() as $class) { |
|
50
|
|
|
foreach ($class->getInterfaces() as $interface) { |
|
51
|
|
|
if (!array_key_exists((string)$interface, $this->implementors)) { |
|
52
|
|
|
$this->implementors[(string)$interface] = []; |
|
53
|
|
|
} |
|
54
|
|
|
$this->implementors[(string)$interface][] = $class->getFqsen(); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param string $type |
|
62
|
|
|
* @param FileBuilder $builder |
|
63
|
|
|
* @param Element $element |
|
|
|
|
|
|
64
|
|
|
*/ |
|
65
|
|
|
public function render($type, &$builder, $element) { |
|
66
|
|
|
if (!$builder instanceof FileBuilder && !$element instanceof Interface_) { |
|
67
|
|
|
return; |
|
68
|
|
|
} |
|
69
|
|
|
if ($type === PhpDomainBuilder::SECTION_AFTER_DESCRIPTION && $builder->getElement() instanceof Interface_) { |
|
70
|
|
|
/** @var Interface_ $interface */ |
|
71
|
|
|
$interface = $builder->getElement(); |
|
72
|
|
|
$content = ''; |
|
73
|
|
|
foreach ($this->implementors[(string)$interface->getFqsen()] as $implementor) { |
|
74
|
|
|
$content .= ':php:class:`' . RstBuilder::escape(substr($implementor, 1)) . '` '; |
|
75
|
|
|
} |
|
76
|
|
|
$builder->addFieldList('Implemented by', $content); |
|
77
|
|
|
$builder->addLine(); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths