1 | <?php |
||
53 | abstract class AbstractTable extends Component implements TableInterface, LoggerAwareInterface |
||
54 | { |
||
55 | use LoggerTrait; |
||
56 | |||
57 | /** |
||
58 | * Indication that table is exists and current schema is fetched from database. |
||
59 | * |
||
60 | * @var bool |
||
61 | */ |
||
62 | private $exists = false; |
||
63 | |||
64 | /** |
||
65 | * Database specific tablePrefix. Required for table renames. |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | private $prefix = ''; |
||
70 | |||
71 | /** |
||
72 | * @invisible |
||
73 | * |
||
74 | * @var Driver |
||
75 | */ |
||
76 | protected $driver = null; |
||
77 | |||
78 | /** |
||
79 | * Initial table state. |
||
80 | * |
||
81 | * @invisible |
||
82 | * @var TableState |
||
83 | */ |
||
84 | protected $initialState = null; |
||
85 | |||
86 | /** |
||
87 | * Currently defined table state. |
||
88 | * |
||
89 | * @invisible |
||
90 | * @var TableState |
||
91 | */ |
||
92 | protected $currentState = null; |
||
93 | |||
94 | /** |
||
95 | * @param Driver $driver Parent driver. |
||
96 | * @param string $name Table name, must include table prefix. |
||
97 | * @param string $prefix Database specific table prefix. |
||
98 | */ |
||
99 | public function __construct(Driver $driver, string $name, string $prefix) |
||
117 | |||
118 | /** |
||
119 | * Get instance of associated driver. |
||
120 | * |
||
121 | * @return Driver |
||
122 | */ |
||
123 | public function getDriver(): Driver |
||
127 | |||
128 | /** |
||
129 | * @return StateComparator |
||
130 | */ |
||
131 | public function getComparator(): StateComparator |
||
135 | |||
136 | /** |
||
137 | * Check if table schema has been modified since synchronization. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | protected function hasChanges(): bool |
||
145 | |||
146 | /** |
||
147 | * {@inheritdoc} |
||
148 | */ |
||
149 | public function exists(): bool |
||
153 | |||
154 | /** |
||
155 | * Return database specific table prefix. |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getPrefix(): string |
||
163 | |||
164 | /** |
||
165 | * Sets table name. Use this function in combination with save to rename table. |
||
166 | * |
||
167 | * @param string $name |
||
168 | * |
||
169 | * @return string Prefixed table name. |
||
170 | */ |
||
171 | public function setName(string $name): string |
||
177 | |||
178 | /** |
||
179 | * {@inheritdoc} |
||
180 | */ |
||
181 | public function getName(): string |
||
185 | |||
186 | /** |
||
187 | * Set table primary keys. Operation can only be applied for newly created tables. Now every |
||
188 | * database might support compound indexes. |
||
189 | * |
||
190 | * @param array $columns |
||
191 | * |
||
192 | * @return self |
||
193 | * |
||
194 | * @throws SchemaException |
||
195 | */ |
||
196 | public function setPrimaryKeys(array $columns): AbstractTable |
||
207 | |||
208 | /** |
||
209 | * {@inheritdoc} |
||
210 | */ |
||
211 | public function getPrimaryKeys(): array |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function hasColumn(string $name): bool |
||
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | * |
||
227 | * @return ColumnInterface[]|AbstractColumn[] |
||
228 | */ |
||
229 | public function getColumns(): array |
||
233 | |||
234 | /** |
||
235 | * {@inheritdoc} |
||
236 | */ |
||
237 | public function hasIndex(array $columns = []): bool |
||
241 | |||
242 | /** |
||
243 | * {@inheritdoc} |
||
244 | * |
||
245 | * @return IndexInterface[]|AbstractIndex[] |
||
246 | */ |
||
247 | public function getIndexes(): array |
||
251 | |||
252 | /** |
||
253 | * {@inheritdoc} |
||
254 | */ |
||
255 | public function hasForeign(string $column): bool |
||
259 | |||
260 | /** |
||
261 | * {@inheritdoc} |
||
262 | * |
||
263 | * @return ReferenceInterface[]|AbstractReference[] |
||
264 | */ |
||
265 | public function getForeigns(): array |
||
269 | |||
270 | /** |
||
271 | * {@inheritdoc} |
||
272 | */ |
||
273 | public function getDependencies(): array |
||
282 | |||
283 | //------ |
||
284 | //Altering operations |
||
285 | //------ |
||
286 | |||
287 | /** |
||
288 | * Reset table state to new form. |
||
289 | * |
||
290 | * @param TableState $state Use null to flush table schema. |
||
291 | * |
||
292 | * @return self|$this |
||
293 | */ |
||
294 | public function setState(TableState $state = null): AbstractTable |
||
305 | |||
306 | /** |
||
307 | * Reset table state to it initial form. |
||
308 | * |
||
309 | * @return self|$this |
||
310 | */ |
||
311 | public function resetState(): AbstractTable |
||
317 | |||
318 | /** |
||
319 | * Populate table schema with values from database. |
||
320 | * |
||
321 | * @param TableState $state |
||
322 | */ |
||
323 | protected function initSchema(TableState $state) |
||
341 | |||
342 | /** |
||
343 | * Fetch index declarations from database. |
||
344 | * |
||
345 | * @return ColumnInterface[] |
||
346 | */ |
||
347 | abstract protected function fetchColumns(): array; |
||
348 | |||
349 | /** |
||
350 | * Fetch index declarations from database. |
||
351 | * |
||
352 | * @return IndexInterface[] |
||
353 | */ |
||
354 | abstract protected function fetchIndexes(): array; |
||
355 | |||
356 | /** |
||
357 | * Fetch references declaration from database. |
||
358 | * |
||
359 | * @return ReferenceInterface[] |
||
360 | */ |
||
361 | abstract protected function fetchReferences(): array; |
||
362 | |||
363 | /** |
||
364 | * Fetch names of primary keys from table. |
||
365 | * |
||
366 | * @return array |
||
367 | */ |
||
368 | abstract protected function fetchPrimaryKeys(): array; |
||
369 | |||
370 | /** |
||
371 | * @return AbstractColumn|string |
||
372 | */ |
||
373 | public function __toString(): string |
||
377 | |||
378 | /** |
||
379 | * @return array |
||
380 | */ |
||
381 | public function __debugInfo() |
||
391 | |||
392 | /** |
||
393 | * @return ContainerInterface |
||
394 | */ |
||
395 | protected function iocContainer() |
||
400 | } |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.