1 | <?php |
||
16 | class GenericAnalyzer |
||
17 | { |
||
18 | /** @var DatabaseInterface */ |
||
19 | protected $database; |
||
20 | |||
21 | /** @var string Metadata class */ |
||
22 | protected $metadataClass = \samsoncms\api\generator\metadata\GenericMetadata::class; |
||
23 | |||
24 | /** |
||
25 | * Generator constructor. |
||
26 | * @param DatabaseInterface $database Database instance |
||
27 | */ |
||
28 | public function __construct(DatabaseInterface $database) |
||
32 | |||
33 | /** |
||
34 | * @return \samsoncms\api\generator\metadata\GenericMetadata[] |
||
35 | */ |
||
36 | public function analyze() |
||
40 | |||
41 | /** |
||
42 | * Get correct field name. |
||
43 | * |
||
44 | * @param string $fieldName Original field name |
||
45 | * |
||
46 | * @return string Correct PHP-supported field name |
||
47 | */ |
||
48 | protected function fieldName($fieldName) |
||
52 | |||
53 | /** |
||
54 | * Transliterate string to english. |
||
55 | * |
||
56 | * @param string $string Source string |
||
57 | * |
||
58 | * @return string Transliterated string |
||
59 | */ |
||
60 | protected function transliterated($string) |
||
111 | |||
112 | /** |
||
113 | * Get correct full entity name with name space. |
||
114 | * |
||
115 | * @param string $navigationName Original navigation entity name |
||
116 | * @param string $namespace Namespace |
||
117 | * |
||
118 | *@return string Correct PHP-supported entity name |
||
119 | */ |
||
120 | protected function fullEntityName($navigationName, $namespace = __NAMESPACE__) |
||
124 | |||
125 | /** |
||
126 | * Get correct entity name. |
||
127 | * |
||
128 | * @param string $navigationName Original navigation entity name |
||
129 | * |
||
130 | *@return string Correct PHP-supported entity name |
||
131 | */ |
||
132 | protected function entityName($navigationName) |
||
136 | |||
137 | /** |
||
138 | * Remove all wrong characters from entity name |
||
139 | * |
||
140 | * @param string $navigationName Original navigation entity name |
||
141 | * |
||
142 | * @return string Correct PHP-supported entity name |
||
143 | */ |
||
144 | protected function getValidName($navigationName) |
||
148 | |||
149 | /** |
||
150 | * Get additional field type in form of Field constant name |
||
151 | * by database additional field type identifier. |
||
152 | * |
||
153 | * @param integer $fieldType Additional field type identifier |
||
154 | * |
||
155 | * @return string Additional field type constant |
||
156 | */ |
||
157 | protected function additionalFieldType($fieldType) |
||
161 | |||
162 | /** |
||
163 | * Get class constant name by its value. |
||
164 | * |
||
165 | * @param string $value Constant value |
||
166 | * @param string $className Class name |
||
167 | * |
||
168 | * @return string Full constant name |
||
169 | */ |
||
170 | protected function constantNameByValue($value, $className = Field::ENTITY) |
||
183 | } |
||
184 | //[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.