1 | <?php |
||
16 | class GenericAnalyzer |
||
17 | { |
||
18 | /** @var array Collection of all parsed metadata by identifiers */ |
||
19 | public static $metadata = []; |
||
20 | |||
21 | /** @var DatabaseInterface */ |
||
22 | protected $database; |
||
23 | |||
24 | /** @var string Metadata class */ |
||
25 | protected $metadataClass = \samsoncms\api\generator\metadata\GenericMetadata::class; |
||
26 | |||
27 | /** |
||
28 | * Generator constructor. |
||
29 | * @param DatabaseInterface $database Database instance |
||
30 | */ |
||
31 | public function __construct(DatabaseInterface $database) |
||
35 | |||
36 | /** |
||
37 | * @return \samsoncms\api\generator\metadata\GenericMetadata[] |
||
38 | */ |
||
39 | public function analyze() |
||
43 | |||
44 | /** |
||
45 | * Get correct entity name. |
||
46 | * |
||
47 | * @param string $navigationName Original navigation entity name |
||
48 | * @return string Correct PHP-supported entity name |
||
49 | */ |
||
50 | protected function entityName($navigationName) |
||
54 | |||
55 | /** |
||
56 | * Remove all wrong characters from entity name |
||
57 | * |
||
58 | * @param string $navigationName Original navigation entity name |
||
59 | * |
||
60 | * @return string Correct PHP-supported entity name |
||
61 | */ |
||
62 | protected function getValidName($navigationName) |
||
66 | |||
67 | /** |
||
68 | * Get correct field name. |
||
69 | * |
||
70 | * @param string $fieldName Original field name |
||
71 | * |
||
72 | * @return string Correct PHP-supported field name |
||
73 | */ |
||
74 | protected function fieldName($fieldName) |
||
78 | /** |
||
79 | * Get correct full entity name with name space. |
||
80 | * |
||
81 | * @param string $navigationName Original navigation entity name |
||
82 | * @param string $namespace Namespace |
||
83 | * @return string Correct PHP-supported entity name |
||
84 | */ |
||
85 | protected function fullEntityName($navigationName, $namespace = __NAMESPACE__) |
||
89 | |||
90 | /** |
||
91 | * Get additional field type in form of Field constant name |
||
92 | * by database additional field type identifier. |
||
93 | * |
||
94 | * @param integer $fieldType Additional field type identifier |
||
95 | * @return string Additional field type constant |
||
96 | */ |
||
97 | protected function additionalFieldType($fieldType) |
||
101 | |||
102 | /** |
||
103 | * Get class constant name by its value. |
||
104 | * |
||
105 | * @param string $value Constant value |
||
106 | * @param string $className Class name |
||
107 | * |
||
108 | * @return string Full constant name |
||
109 | */ |
||
110 | protected function constantNameByValue($value, $className = Field::ENTITY) |
||
123 | |||
124 | /** |
||
125 | * Transliterate string to english. |
||
126 | * |
||
127 | * @param string $string Source string |
||
128 | * @return string Transliterated string |
||
129 | */ |
||
130 | protected function transliterated($string) |
||
181 | } |
||
182 | //[PHPCOMPRESSOR(remove,end)] |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.