1 | <?php |
||
16 | class Generator |
||
17 | { |
||
18 | /** @var DatabaseInterface */ |
||
19 | protected $database; |
||
20 | |||
21 | /** |
||
22 | * Transliterate string to english. |
||
23 | * |
||
24 | * @param string $string Source string |
||
25 | * @return string Transliterated string |
||
26 | */ |
||
27 | protected function transliterated($string) |
||
78 | |||
79 | /** |
||
80 | * Get class constant name by its value. |
||
81 | * |
||
82 | * @param string $value Constant value |
||
83 | * @param string $className Class name |
||
84 | * @return string Full constant name |
||
85 | */ |
||
86 | protected function constantNameByValue($value, $className = Field::ENTITY) |
||
97 | |||
98 | /** |
||
99 | * Get correct entity name. |
||
100 | * |
||
101 | * @param string $navigationName Original navigation entity name |
||
102 | * @return string Correct PHP-supported entity name |
||
103 | */ |
||
104 | protected function entityName($navigationName) |
||
108 | |||
109 | /** |
||
110 | * Get correct full entity name with name space. |
||
111 | * |
||
112 | * @param string $navigationName Original navigation entity name |
||
113 | * @param string $namespace Namespace |
||
114 | * @return string Correct PHP-supported entity name |
||
115 | */ |
||
116 | protected function fullEntityName($navigationName, $namespace = __NAMESPACE__) |
||
120 | |||
121 | /** |
||
122 | * Get correct field name. |
||
123 | * |
||
124 | * @param string $fieldName Original field name |
||
125 | * @return string Correct PHP-supported field name |
||
126 | */ |
||
127 | protected function fieldName($fieldName) |
||
131 | |||
132 | /** |
||
133 | * Get additional field type in form of Field constant name |
||
134 | * by database additional field type identifier. |
||
135 | * |
||
136 | * @param integer $fieldType Additional field type identifier |
||
137 | * @return string Additional field type constant |
||
138 | */ |
||
139 | protected function additionalFieldType($fieldType) |
||
143 | |||
144 | /** |
||
145 | * Create entity PHP class code. |
||
146 | * |
||
147 | * @param string $navigationName Original entity name |
||
148 | * @param string $entityName PHP entity name |
||
149 | * @param array $navigationFields Collection of entity additional fields |
||
150 | * @return string Generated entity query PHP class code |
||
151 | */ |
||
152 | protected function createEntityClass($navigationName, $entityName, $navigationFields) |
||
173 | |||
174 | /** |
||
175 | * Generate Query::where() analog for specific field. |
||
176 | * |
||
177 | * @param string $fieldName Field name |
||
178 | * @param string $fieldId Field primary identifier |
||
179 | * @param string $fieldType Field PHP type |
||
180 | * @return string Generated PHP method code |
||
181 | */ |
||
182 | protected function generateFieldConditionMethod($fieldName, $fieldId, $fieldType) |
||
196 | |||
197 | /** |
||
198 | * Create entity query PHP class code. |
||
199 | * |
||
200 | * @param integer $navigationID Entity navigation identifier |
||
201 | * @param string $navigationName Original entity name |
||
202 | * @param string $entityName PHP entity name |
||
203 | * @param array $navigationFields Collection of entity additional fields |
||
204 | * @return string Generated entity query PHP class code |
||
205 | */ |
||
206 | protected function createQueryClass($navigationID, $navigationName, $entityName, $navigationFields) |
||
239 | |||
240 | /** @return string Entity state hash */ |
||
241 | public function entityHash() |
||
250 | |||
251 | /** @return array Get collection of navigation objects */ |
||
252 | protected function entityNavigations($type = 0) |
||
259 | |||
260 | /** @return array Collection of navigation additional fields */ |
||
261 | protected function navigationFields($navigationID) |
||
273 | |||
274 | /** |
||
275 | * Generate entity classes. |
||
276 | * |
||
277 | * @param string $namespace Base namespace for generated classes |
||
278 | * @return string Generated PHP code for entity classes |
||
279 | */ |
||
280 | public function createEntityClasses($namespace = __NAMESPACE__) |
||
309 | |||
310 | /** |
||
311 | * Generator constructor. |
||
312 | * @param DatabaseInterface $database Database instance |
||
313 | */ |
||
314 | public function __construct(DatabaseInterface $database) |
||
318 | } |
||
319 |
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.