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
|
11 |
|
protected function configure() |
13
|
|
|
{ |
14
|
11 |
|
$this |
15
|
11 |
|
->setName('write') |
16
|
11 |
|
->setDescription('Generates PlantUML diagram from php source') |
17
|
11 |
|
->addArgument( |
18
|
11 |
|
'files', |
19
|
|
|
InputArgument::IS_ARRAY |
20
|
11 |
|
) |
21
|
11 |
|
->addOption('without-constants', null, null, 'Disables rendering of constants') |
22
|
11 |
|
->addOption('without-methods', null, null, 'Disables rendering of methods') |
23
|
11 |
|
->addOption('without-properties', null, null, 'Disables rendering of properties') |
24
|
11 |
|
->addOption('without-doc-content', null, null, 'Disables parsing doc block for methods or properties') |
25
|
11 |
|
->addOption('grouping', null, null, 'Enable deprecated and todo grouping for methods'); |
26
|
11 |
|
} |
27
|
|
|
|
28
|
11 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
29
|
|
|
{ |
30
|
11 |
|
$broker = new \TokenReflection\Broker(new \TokenReflection\Broker\Backend\Memory()); |
31
|
|
|
|
32
|
11 |
|
foreach ($input->getArgument('files') as $fileToProcess) { |
33
|
11 |
|
if (is_dir($fileToProcess)) { |
34
|
|
|
$broker->processDirectory($fileToProcess); |
35
|
|
|
} |
36
|
|
|
else { |
37
|
11 |
|
$broker->processFile($fileToProcess); |
38
|
|
|
} |
39
|
11 |
|
} |
40
|
|
|
|
41
|
11 |
|
$classWriter = new \Flagbit\Plantuml\TokenReflection\ClassWriter(); |
42
|
11 |
|
if (!$input->getOption('without-constants')) { |
43
|
11 |
|
$classWriter->setConstantWriter(new \Flagbit\Plantuml\TokenReflection\ConstantWriter()); |
44
|
11 |
|
} |
45
|
11 |
|
if (!$input->getOption('without-properties')) { |
46
|
11 |
|
if ($input->getOption('grouping')) { |
47
|
1 |
|
$classWriter->setPropertyWriter(new \Flagbit\Plantuml\TokenReflection\PropertyGroupingWriter()); |
48
|
1 |
|
} else { |
49
|
10 |
|
$classWriter->setPropertyWriter(new \Flagbit\Plantuml\TokenReflection\PropertyWriter()); |
50
|
|
|
} |
51
|
11 |
|
} |
52
|
11 |
|
if (!$input->getOption('without-methods')) { |
53
|
11 |
|
if ($input->getOption('grouping')) { |
54
|
1 |
|
$classWriter->setMethodWriter(new \Flagbit\Plantuml\TokenReflection\MethodGroupingWriter()); |
55
|
1 |
|
} else { |
56
|
10 |
|
$classWriter->setMethodWriter(new \Flagbit\Plantuml\TokenReflection\MethodWriter()); |
57
|
|
|
} |
58
|
11 |
|
} |
59
|
11 |
|
if (!$input->getOption('without-doc-content')) { |
60
|
11 |
|
$classWriter->setDocContentWriter(new \Flagbit\Plantuml\TokenReflection\DocContentWriter()); |
61
|
11 |
|
} |
62
|
|
|
|
63
|
11 |
|
$output->write('@startuml', "\n"); |
|
|
|
|
64
|
11 |
|
foreach ($broker->getClasses() as $class) { |
65
|
|
|
/** @var $class \TokenReflection\IReflectionClass */ |
66
|
11 |
|
$output->write($classWriter->writeElement($class)); |
67
|
11 |
|
} |
68
|
11 |
|
$output->write('@enduml', "\n"); |
|
|
|
|
69
|
11 |
|
} |
70
|
|
|
} |
71
|
|
|
|
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: