1 | <?php |
||
16 | class Generic |
||
17 | { |
||
18 | /** @var array Collection of all parsed metadata by identifiers */ |
||
19 | public static $metadata = []; |
||
20 | |||
21 | /** @var DatabaseInterface */ |
||
22 | protected $database; |
||
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\Generic[] |
||
35 | */ |
||
36 | public function analyze() |
||
40 | |||
41 | /** |
||
42 | * Get correct entity name. |
||
43 | * |
||
44 | * @param string $navigationName Original navigation entity name |
||
45 | * @return string Correct PHP-supported entity name |
||
46 | */ |
||
47 | protected function entityName($navigationName) |
||
51 | |||
52 | /** |
||
53 | * Remove all wrong characters from entity name |
||
54 | * |
||
55 | * @param string $navigationName Original navigation entity name |
||
56 | * |
||
57 | * @return string Correct PHP-supported entity name |
||
58 | */ |
||
59 | protected function getValidName($navigationName) |
||
63 | |||
64 | /** |
||
65 | * Get correct field name. |
||
66 | * |
||
67 | * @param string $fieldName Original field name |
||
68 | * |
||
69 | * @return string Correct PHP-supported field name |
||
70 | */ |
||
71 | protected function fieldName($fieldName) |
||
75 | /** |
||
76 | * Get correct full entity name with name space. |
||
77 | * |
||
78 | * @param string $navigationName Original navigation entity name |
||
79 | * @param string $namespace Namespace |
||
80 | * @return string Correct PHP-supported entity name |
||
81 | */ |
||
82 | protected function fullEntityName($navigationName, $namespace = __NAMESPACE__) |
||
86 | |||
87 | /** |
||
88 | * Get additional field type in form of Field constant name |
||
89 | * by database additional field type identifier. |
||
90 | * |
||
91 | * @param integer $fieldType Additional field type identifier |
||
92 | * @return string Additional field type constant |
||
93 | */ |
||
94 | protected function additionalFieldType($fieldType) |
||
98 | |||
99 | /** |
||
100 | * Get class constant name by its value. |
||
101 | * |
||
102 | * @param string $value Constant value |
||
103 | * @param string $className Class name |
||
104 | * |
||
105 | * @return string Full constant name |
||
106 | */ |
||
107 | protected function constantNameByValue($value, $className = Field::ENTITY) |
||
120 | |||
121 | /** |
||
122 | * Transliterate string to english. |
||
123 | * |
||
124 | * @param string $string Source string |
||
125 | * @return string Transliterated string |
||
126 | */ |
||
127 | protected function transliterated($string) |
||
178 | } |
||
179 | //[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.