1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Flagbit\Plantuml\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Command\Command; |
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
9
|
|
|
|
10
|
|
|
class WriteCommand extends Command |
11
|
|
|
{ |
12
|
10 |
|
protected function configure() |
13
|
|
|
{ |
14
|
10 |
|
$this |
15
|
10 |
|
->setName('write') |
16
|
10 |
|
->setDescription('Generates PlantUML diagram from php source') |
17
|
10 |
|
->addArgument( |
18
|
10 |
|
'files', |
19
|
|
|
InputArgument::IS_ARRAY |
20
|
10 |
|
) |
21
|
10 |
|
->addOption('without-constants', null, null, 'Disables rendering of constants') |
22
|
10 |
|
->addOption('without-methods', null, null, 'Disables rendering of methods') |
23
|
10 |
|
->addOption('without-properties', null, null, 'Disables rendering of properties') |
24
|
10 |
|
->addOption('without-doc-content', null, null, 'Disables parsing doc block for methods or properties'); |
25
|
10 |
|
} |
26
|
|
|
|
27
|
10 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
28
|
|
|
{ |
29
|
10 |
|
$broker = new \TokenReflection\Broker(new \TokenReflection\Broker\Backend\Memory()); |
30
|
|
|
|
31
|
10 |
|
foreach ($input->getArgument('files') as $fileToProcess) { |
32
|
10 |
|
if (is_dir($fileToProcess)) { |
33
|
|
|
$broker->processDirectory($fileToProcess); |
34
|
|
|
} |
35
|
|
|
else { |
36
|
10 |
|
$broker->processFile($fileToProcess); |
37
|
|
|
} |
38
|
10 |
|
} |
39
|
|
|
|
40
|
10 |
|
$classWriter = new \Flagbit\Plantuml\TokenReflection\ClassWriter(); |
41
|
10 |
|
if (!$input->getOption('without-constants')) { |
42
|
10 |
|
$classWriter->setConstantWriter(new \Flagbit\Plantuml\TokenReflection\ConstantWriter()); |
43
|
10 |
|
} |
44
|
10 |
|
if (!$input->getOption('without-properties')) { |
45
|
10 |
|
$classWriter->setPropertyWriter(new \Flagbit\Plantuml\TokenReflection\PropertyWriter()); |
46
|
10 |
|
} |
47
|
10 |
|
if (!$input->getOption('without-methods')) { |
48
|
10 |
|
$classWriter->setMethodWriter(new \Flagbit\Plantuml\TokenReflection\MethodWriter()); |
49
|
10 |
|
} |
50
|
10 |
|
if (!$input->getOption('without-doc-content')) { |
51
|
10 |
|
$classWriter->setDocContentWriter(new \Flagbit\Plantuml\TokenReflection\DocContentWriter()); |
52
|
10 |
|
} |
53
|
|
|
|
54
|
10 |
|
$output->write('@startuml', "\n"); |
|
|
|
|
55
|
10 |
|
foreach ($broker->getClasses() as $class) { |
56
|
|
|
/** @var $class \TokenReflection\IReflectionClass */ |
57
|
10 |
|
$output->write($classWriter->writeElement($class)); |
58
|
10 |
|
} |
59
|
10 |
|
$output->write('@enduml', "\n"); |
|
|
|
|
60
|
10 |
|
} |
61
|
|
|
} |
62
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: