|
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 |
|
->addOption('grouping', null, null, 'Enable deprecated and todo grouping for methods') |
|
26
|
|
|
->addOption('without-function-params', null, null, 'Do not display function param, only count'); |
|
27
|
10 |
|
} |
|
28
|
|
|
|
|
29
|
10 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
30
|
|
|
{ |
|
31
|
10 |
|
$broker = new \TokenReflection\Broker(new \TokenReflection\Broker\Backend\Memory()); |
|
32
|
10 |
|
|
|
33
|
|
|
foreach ($input->getArgument('files') as $fileToProcess) { |
|
34
|
|
|
if (is_dir($fileToProcess)) { |
|
35
|
|
|
$broker->processDirectory($fileToProcess); |
|
36
|
10 |
|
} |
|
37
|
|
|
else { |
|
38
|
10 |
|
$broker->processFile($fileToProcess); |
|
39
|
|
|
} |
|
40
|
10 |
|
} |
|
41
|
10 |
|
|
|
42
|
10 |
|
$writerOptions = new \Flagbit\Plantuml\TokenReflection\WriterOptions(); |
|
43
|
10 |
|
if ($input->getOption('without-function-params')) { |
|
44
|
10 |
|
$writerOptions->withoutFunctionParameter = true; |
|
|
|
|
|
|
45
|
10 |
|
} |
|
46
|
10 |
|
|
|
47
|
10 |
|
$classWriter = new \Flagbit\Plantuml\TokenReflection\ClassWriter(); |
|
48
|
10 |
|
if (!$input->getOption('without-constants')) { |
|
49
|
10 |
|
$classWriter->setConstantWriter(new \Flagbit\Plantuml\TokenReflection\ConstantWriter()); |
|
50
|
10 |
|
} |
|
51
|
10 |
|
if (!$input->getOption('without-properties')) { |
|
52
|
10 |
|
if ($input->getOption('grouping')) { |
|
53
|
|
|
$classWriter->setPropertyWriter(new \Flagbit\Plantuml\TokenReflection\PropertyGroupingWriter()); |
|
54
|
10 |
|
} else { |
|
55
|
10 |
|
$classWriter->setPropertyWriter(new \Flagbit\Plantuml\TokenReflection\PropertyWriter()); |
|
56
|
|
|
} |
|
57
|
10 |
|
} |
|
58
|
10 |
|
if (!$input->getOption('without-methods')) { |
|
59
|
10 |
|
if ($input->getOption('grouping')) { |
|
60
|
10 |
|
$classWriter->setMethodWriter(new \Flagbit\Plantuml\TokenReflection\MethodGroupingWriter($writerOptions)); |
|
61
|
|
|
} else { |
|
62
|
1 |
|
$classWriter->setMethodWriter(new \Flagbit\Plantuml\TokenReflection\MethodWriter($writerOptions)); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
if (!$input->getOption('without-doc-content')) { |
|
66
|
|
|
$classWriter->setDocContentWriter(new \Flagbit\Plantuml\TokenReflection\DocContentWriter()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$output->write('@startuml', "\n"); |
|
|
|
|
|
|
70
|
|
|
foreach ($broker->getClasses() as $class) { |
|
71
|
|
|
/** @var $class \TokenReflection\IReflectionClass */ |
|
72
|
|
|
$output->write($classWriter->writeElement($class)); |
|
73
|
|
|
} |
|
74
|
|
|
$output->write('@enduml', "\n"); |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.