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