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