|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace micro\utils\yuml; |
|
4
|
|
|
|
|
5
|
|
|
use micro\cache\CacheManager; |
|
6
|
|
|
use micro\controllers\Startup; |
|
7
|
|
|
use micro\cache\ClassUtils; |
|
8
|
|
|
use micro\utils\StrUtils; |
|
9
|
|
|
|
|
10
|
|
|
class ClassesToYuml { |
|
11
|
|
|
private $displayProperties; |
|
12
|
|
|
private $displayAssociations; |
|
13
|
|
|
private $displayMethods; |
|
14
|
|
|
private $displayMethodsParams; |
|
15
|
|
|
private $displayPropertiesTypes; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct($displayProperties=true, $displayAssociations=true, $displayMethods=false, $displayMethodsParams=false, $displayPropertiesTypes=false) { |
|
18
|
|
|
$this->displayProperties=$displayProperties; |
|
19
|
|
|
$this->displayAssociations=$displayAssociations; |
|
20
|
|
|
$this->displayMethods=$displayMethods; |
|
21
|
|
|
$this->displayMethodsParams=$displayMethodsParams; |
|
22
|
|
|
$this->displayPropertiesTypes=$displayPropertiesTypes; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* |
|
27
|
|
|
* @param boolean $displayProperties |
|
|
|
|
|
|
28
|
|
|
* @param boolean $displayAssociations |
|
|
|
|
|
|
29
|
|
|
* @param boolean $displayMethods |
|
|
|
|
|
|
30
|
|
|
* @param boolean $displayMethodsParams |
|
|
|
|
|
|
31
|
|
|
* @param boolean $displayPropertiesTypes |
|
|
|
|
|
|
32
|
|
|
* @return ClassParser[]|string[] |
|
33
|
|
|
*/ |
|
34
|
|
|
public function parse() { |
|
35
|
|
|
$yumlResult=[ ]; |
|
36
|
|
|
$config=Startup::getConfig(); |
|
37
|
|
|
$files=CacheManager::getModelsFiles($config, true); |
|
38
|
|
|
if (\sizeof($files) !== 0) { |
|
39
|
|
|
foreach ( $files as $file ) { |
|
40
|
|
|
$completeName=ClassUtils::getClassFullNameFromFile($file); |
|
41
|
|
|
$yumlR=new ClassToYuml($completeName, $this->displayProperties, false, $this->displayMethods, $this->displayMethodsParams, $this->displayPropertiesTypes, false); |
|
42
|
|
|
$yumlResult[]=$yumlR; |
|
43
|
|
|
} |
|
44
|
|
|
if ($this->displayAssociations) { |
|
45
|
|
|
$count=\sizeof($files); |
|
46
|
|
|
for($i=0; $i < $count; $i++) { |
|
47
|
|
|
$result=$yumlResult[$i]->oneToManyTostring(); |
|
48
|
|
|
if (StrUtils::isNotNull($result)) |
|
49
|
|
|
$yumlResult[]=$result; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
return $yumlResult; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function __toString() { |
|
57
|
|
|
return \implode(Yuml::$groupeSeparator, $this->parse()); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.