1 | <?php declare(strict_types=1); |
||
12 | class TableDataDumper { |
||
13 | /** |
||
14 | * Amount of rows to process per SELECT statement |
||
15 | */ |
||
16 | public const CHUNK_SIZE = 1000; |
||
17 | |||
18 | /** |
||
19 | * @var TableDumper TableDumper instance related to this data dumper |
||
20 | */ |
||
21 | protected $tableDumper; |
||
22 | |||
23 | /** |
||
24 | * @param TableDumper TableDumper this data dumper will be based on |
||
25 | */ |
||
26 | 27 | public function __construct(TableDumper $tableDumper) |
|
30 | |||
31 | /** |
||
32 | * Prepares the SELECT statement that will be used to get the data |
||
33 | * @param PDO $db PDO instance to use for DB queries |
||
34 | * @return PDOStatement Returns the PDOStatement for to be used for processing chunks |
||
35 | */ |
||
36 | 27 | protected function prepareSelect(PDO $db): PDOStatement |
|
53 | |||
54 | /** |
||
55 | * Gets the data for a chunk of rows and writes this part of the statement to the dump stream |
||
56 | * @param PDOStatement $stmt SELECT statement to get data for the chunk |
||
57 | * @param resource $stream Stream to write to |
||
58 | * @param int $chunkIndex Index of the chunk to process |
||
59 | * @return int Returns the current row index after processing this chunk |
||
60 | */ |
||
61 | 27 | protected function processChunk(PDOStatement $stmt, $stream, int $chunkIndex): int |
|
82 | |||
83 | /** |
||
84 | * Prepare the first part of the INSERT statement |
||
85 | * @param array $listCols List columns to include in that INSERT statement |
||
86 | * @return string Returns the first of the INSERT statement |
||
87 | */ |
||
88 | 24 | protected function prepareInsert(array $listCols): string |
|
99 | |||
100 | /** |
||
101 | * Takes a list of values for one row and prepares the string for the INSERT statement |
||
102 | * @param array $listValues List of values for that row |
||
103 | * @param bool $first TRUE if this is the first row, FALSE otherwise |
||
104 | * @return string Return the values for that row as a string for the INSERT statement |
||
105 | */ |
||
106 | 24 | protected function prepareRow(array $listValues, bool $first): string |
|
126 | |||
127 | /** |
||
128 | * Writes an INSERT statement for the data to the dump stream |
||
129 | * |
||
130 | * @param PDO $db PDO instance to use for DB queries |
||
131 | * @param resource $stream Stream to write the statement to |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | 27 | public function dump(PDO $db, $stream): void |
|
153 | } |
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.