|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP version 7.1 |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the license that is bundled with this package in the file LICENSE. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace PhUml\Console\Commands; |
|
9
|
|
|
|
|
10
|
|
|
use PhUml\Configuration\DigraphConfiguration; |
|
11
|
|
|
use PhUml\Configuration\DotFileBuilder; |
|
12
|
|
|
use PhUml\Parser\CodebaseDirectory; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
|
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* This command will generate file in `DOT` format that is ready to use to generate a UML class |
|
19
|
|
|
* diagram using either `neato` or `dot` |
|
20
|
|
|
* |
|
21
|
|
|
* This command has 2 required arguments |
|
22
|
|
|
* |
|
23
|
|
|
* 1. `directory`. The path where your codebase lives |
|
24
|
|
|
* 2. `output`. The path to where the generated `gv` file will be saved |
|
25
|
|
|
* |
|
26
|
|
|
* @see WithDigraphConfiguration::addDigraphOptions() for more details about all the available options |
|
27
|
|
|
*/ |
|
28
|
|
|
class GenerateDotFileCommand extends GeneratorCommand |
|
29
|
|
|
{ |
|
30
|
|
|
use WithDigraphConfiguration; |
|
31
|
|
|
|
|
32
|
72 |
|
protected function configure(): void |
|
33
|
|
|
{ |
|
34
|
|
|
$this |
|
35
|
72 |
|
->setName('phuml:dot') |
|
36
|
72 |
|
->setDescription('Generates a digraph in DOT format of a given directory') |
|
37
|
72 |
|
->setHelp( |
|
38
|
|
|
<<<HELP |
|
39
|
72 |
|
Example: |
|
40
|
|
|
php bin/phuml phuml:dot -r -a ./src dot.gv |
|
41
|
|
|
|
|
42
|
|
|
This command will look for PHP files within the `./src` directory and its sub-directories. |
|
43
|
|
|
It will extract associations from constructor parameters and attributes. |
|
44
|
|
|
It will generate a digraph in DOT format and save it to the file `dot.gv`. |
|
45
|
|
|
HELP |
|
46
|
|
|
) |
|
47
|
72 |
|
->addArgument( |
|
48
|
72 |
|
'directory', |
|
49
|
72 |
|
InputArgument::REQUIRED, |
|
50
|
72 |
|
'The directory to be scanned to generate the DOT file' |
|
51
|
|
|
) |
|
52
|
72 |
|
->addArgument( |
|
53
|
72 |
|
'output', |
|
54
|
72 |
|
InputArgument::REQUIRED, |
|
55
|
72 |
|
'The file name for your DOT file' |
|
56
|
|
|
) |
|
57
|
|
|
; |
|
58
|
72 |
|
$this->addDigraphOptions($this); |
|
59
|
72 |
|
} |
|
60
|
|
|
|
|
61
|
12 |
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
62
|
|
|
{ |
|
63
|
12 |
|
$generatorInput = new GeneratorInput($input->getArguments(), $input->getOptions()); |
|
64
|
12 |
|
$codebasePath = $generatorInput->directory(); |
|
65
|
|
|
$dotFilePath = $generatorInput->outputFile(); |
|
66
|
12 |
|
|
|
67
|
|
|
$builder = new DotFileBuilder(new DigraphConfiguration($generatorInput->options())); |
|
68
|
12 |
|
|
|
69
|
12 |
|
$dotFileGenerator = $builder->dotFileGenerator(); |
|
70
|
|
|
$dotFileGenerator->attach($this->display); |
|
71
|
12 |
|
|
|
72
|
12 |
|
$codeFinder = $builder->codeFinder(); |
|
73
|
|
|
$codeFinder->addDirectory(CodebaseDirectory::from($codebasePath)); |
|
74
|
9 |
|
|
|
75
|
|
|
$dotFileGenerator->generate($codeFinder, $dotFilePath); |
|
76
|
9 |
|
|
|
77
|
|
|
return self::SUCCESS; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
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