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 InvalidArgumentException; |
||
9 | use PhUml\Console\ConsoleProgressDisplay; |
||
10 | use PhUml\Generators\ClassDiagramConfiguration; |
||
11 | use PhUml\Generators\ClassDiagramGenerator; |
||
12 | use Symfony\Component\Console\Command\Command; |
||
0 ignored issues
–
show
|
|||
13 | use Symfony\Component\Console\Input\InputArgument; |
||
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputArgument was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | use Symfony\Component\Console\Input\InputInterface; |
||
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
15 | use Symfony\Component\Console\Input\InputOption; |
||
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputOption was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
16 | use Symfony\Component\Console\Output\OutputInterface; |
||
0 ignored issues
–
show
The type
Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
17 | |||
18 | /** |
||
19 | * This command will generate a UML class diagram by reading an OO codebase |
||
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 `png` image will be saved |
||
25 | * |
||
26 | * There is 1 option specific to this command |
||
27 | * |
||
28 | * 1. `processor`. The command to be used to create the `png` image, it can be either `neato` or `dot` |
||
29 | * This is the only required option |
||
30 | * |
||
31 | * @see WithDigraphConfiguration::addDigraphOptions() for more details about the rest of the options |
||
32 | */ |
||
33 | final class GenerateClassDiagramCommand extends Command |
||
34 | { |
||
35 | use WithDigraphConfiguration; |
||
36 | |||
37 | /** @throws InvalidArgumentException */ |
||
38 | 17 | protected function configure(): void |
|
39 | { |
||
40 | $this |
||
41 | 17 | ->setName('phuml:diagram') |
|
42 | 17 | ->setDescription('Generate a class diagram scanning the given directory') |
|
43 | 17 | ->setHelp( |
|
44 | <<<HELP |
||
45 | Example: |
||
46 | php bin/phuml phuml:diagram -r -a -p neato ./src out.png |
||
47 | |||
48 | This command will look for PHP files within the `./src` directory and its sub-directories. |
||
49 | It will extract associations from constructor parameters and properties. |
||
50 | It will generate the class diagram using the `neato` processor |
||
51 | It will save the diagram to the file `out.png`. |
||
52 | HELP |
||
53 | ) |
||
54 | 17 | ->addArgument( |
|
55 | 'directory', |
||
56 | InputArgument::REQUIRED, |
||
57 | 'The directory to be scanned to generate the class diagram' |
||
58 | ) |
||
59 | 17 | ->addArgument( |
|
60 | 'output', |
||
61 | InputArgument::REQUIRED, |
||
62 | 'The file name for your class diagram' |
||
63 | ) |
||
64 | 17 | ->addOption( |
|
65 | 'processor', |
||
66 | 'p', |
||
67 | InputOption::VALUE_REQUIRED, |
||
68 | 'Choose between the neato and dot processors' |
||
69 | ) |
||
70 | ; |
||
71 | 17 | $this->addDigraphOptions($this); |
|
72 | } |
||
73 | |||
74 | 7 | protected function execute(InputInterface $input, OutputInterface $output): int |
|
75 | { |
||
76 | /** |
||
77 | * @var array{ |
||
78 | * processor: string, |
||
79 | * recursive: bool, |
||
80 | * associations: bool, |
||
81 | * "hide-private": bool, |
||
82 | * "hide-protected": bool, |
||
83 | * "hide-methods": bool, |
||
84 | * "hide-attributes": bool, |
||
85 | * "hide-empty-blocks": bool, |
||
86 | * theme: string |
||
87 | * } $options |
||
88 | */ |
||
89 | 7 | $options = $input->getOptions(); |
|
90 | 7 | $configuration = new ClassDiagramConfiguration($options, new ConsoleProgressDisplay($output)); |
|
91 | 7 | $generator = ClassDiagramGenerator::fromConfiguration($configuration); |
|
92 | |||
93 | /** |
||
94 | * @var array{ |
||
95 | * directory: string, |
||
96 | * output: string |
||
97 | * } $arguments |
||
98 | */ |
||
99 | 7 | $arguments = $input->getArguments(); |
|
100 | 7 | $generator->generate(GeneratorInput::pngFile($arguments)); |
|
101 | |||
102 | 6 | return self::SUCCESS; |
|
103 | } |
||
104 | } |
||
105 |
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