1 | <?php |
||
28 | class Writer |
||
29 | { |
||
30 | /** |
||
31 | * Doctrine conection handler |
||
32 | * @var \Doctrine\DBAL\Connection |
||
33 | */ |
||
34 | private $conn; |
||
35 | |||
36 | /** |
||
37 | * Should I protect the cols ? That will also protect the Primary Keys |
||
38 | * |
||
39 | * @var boolean |
||
40 | */ |
||
41 | protected $protectCols = true; |
||
42 | |||
43 | /** |
||
44 | * List the cols to protected. Could containe regexp |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $protectedCols = ['id', 'parent_id']; |
||
49 | |||
50 | /** |
||
51 | * List of tables patterns to ignore |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $ignoredTables = []; |
||
56 | |||
57 | /** |
||
58 | * Store the tables added to the conf |
||
59 | * |
||
60 | * @var array |
||
61 | */ |
||
62 | 7 | protected $tablesInConf = []; |
|
63 | |||
64 | 7 | /** |
|
65 | * Set Change Id to ask the writer to ignore (or not) the protectedCols |
||
66 | 7 | * |
|
67 | * @param bool |
||
68 | */ |
||
69 | public function protectCols(bool $protect): Writer |
||
75 | |||
76 | 5 | /** |
|
77 | * Set protected cols |
||
78 | 5 | * |
|
79 | * @param array $cols |
||
80 | */ |
||
81 | public function setProtectedCols(array $cols): Writer |
||
87 | |||
88 | 5 | /** |
|
89 | * Set protected cols |
||
90 | 5 | * |
|
91 | * @param array $tables |
||
92 | */ |
||
93 | public function setIgnoredTables(array $tables): Writer |
||
99 | |||
100 | 1 | /** |
|
101 | * Get Tables List added to the conf |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | public function getTablesInConf(): array |
||
109 | |||
110 | /** |
||
111 | 11 | * Generate the configuration by reading tables + cols |
|
112 | * |
||
113 | * @param DB $db |
||
114 | * @param GuesserInterface $guesser |
||
115 | 11 | * |
|
116 | 11 | * @return array |
|
117 | 3 | */ |
|
118 | public function generateConfFromDB(DB $db, GuesserInterface $guesser): array |
||
146 | |||
147 | 5 | /** |
|
148 | 1 | * Save the data to the file as YAML |
|
149 | * |
||
150 | * @param array $data |
||
151 | 4 | * @param string $filename |
|
152 | 4 | */ |
|
153 | public function save(array $data, string $filename) |
||
161 | |||
162 | /** |
||
163 | 8 | * Check if that col has to be ignored |
|
164 | * |
||
165 | 8 | * @param string $table |
|
166 | 2 | * @param string $col |
|
167 | * @param bool $isPrimary |
||
|
|||
168 | * |
||
169 | 6 | * @return bool |
|
170 | 6 | */ |
|
171 | 6 | protected function colIgnored(string $table, string $col): bool |
|
185 | 11 | ||
186 | /** |
||
187 | 11 | * Get the table lists from a connection |
|
188 | * |
||
189 | 11 | * @return array |
|
190 | 11 | */ |
|
191 | 10 | protected function getTablesList(): array |
|
207 | |||
208 | /** |
||
209 | * Get the cols lists from a connection + table |
||
210 | 8 | * |
|
211 | * @param string $table |
||
212 | 8 | * |
|
213 | * @return array |
||
214 | 8 | */ |
|
215 | 8 | protected function getColsList(string $table): array |
|
242 | 7 | ||
243 | /** |
||
244 | * Guess the cols with the guesser |
||
245 | * |
||
246 | * @param string $table |
||
247 | 8 | * @param array $cols |
|
248 | 1 | * @param GuesserInterface $guesser |
|
249 | * |
||
250 | * @return array |
||
251 | 7 | */ |
|
252 | protected function guessColsAnonType(string $table, array $cols, GuesserInterface $guesser): array |
||
261 | |||
262 | /** |
||
263 | 6 | * Check if that table has to be ignored |
|
264 | * |
||
265 | 6 | * @param string $table |
|
266 | 6 | * |
|
267 | 6 | * @return bool |
|
268 | */ |
||
269 | protected function tableIgnored(string $table): bool |
||
279 | } |
||
280 |
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
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.