1 | <?php |
||
19 | class ReplicaMasterAwareRecordIdsAcquirer { |
||
20 | |||
21 | /** |
||
22 | * @var Database $dbMaster |
||
23 | */ |
||
24 | private $dbMaster; |
||
25 | |||
26 | /** |
||
27 | * @var Database $dbReplica |
||
28 | */ |
||
29 | private $dbReplica; |
||
30 | |||
31 | /** @var string $table */ |
||
32 | private $table; |
||
33 | |||
34 | /** @var string $idColumn */ |
||
35 | private $idColumn; |
||
36 | |||
37 | /** @var LoggerInterface $logger */ |
||
38 | private $logger; |
||
39 | |||
40 | /** |
||
41 | * @param IDatabase $dbMaster master database to insert non-existing records into |
||
42 | * @param IDatabase $dbReplica replica database to initially query existing records in |
||
43 | * @param string $table the name of the table this acquirer is for |
||
44 | * @param string $idColumn the name of the column that contains the desired ids |
||
45 | * @param LoggerInterface $logger |
||
46 | */ |
||
47 | public function __construct( |
||
60 | |||
61 | /** |
||
62 | * Acquire ids of needed records in the table, inserting non-existing |
||
63 | * ones into master database. |
||
64 | * |
||
65 | * Note: this function assumes that all records given in this array specify |
||
66 | * the same columns. If some records specify less, more or different columns than |
||
67 | * the first one does, the behavior is not defined. |
||
68 | * |
||
69 | * @param array $neededRecords array of records to be looked-up or inserted. |
||
70 | * Each entry in this array should an associative array of column => value pairs. |
||
71 | * Example: |
||
72 | * [ |
||
73 | * [ 'columnA' => 'valueA1', 'columnB' => 'valueB1' ], |
||
74 | * [ 'columnA' => 'valueA2', 'columnB' => 'valueB2' ], |
||
75 | * ... |
||
76 | * ] |
||
77 | * |
||
78 | * @return array the array of input recrods along with their ids |
||
79 | * Example: |
||
80 | * [ |
||
81 | * [ 'columnA' => 'valueA1', 'columnB' => 'valueB1', 'idColumn' => '1' ], |
||
82 | * [ 'columnA' => 'valueA2', 'columnB' => 'valueB2', 'idColumn' => '2' ], |
||
83 | * ... |
||
84 | * ] |
||
85 | */ |
||
86 | public function acquireIds( array $neededRecords ) { |
||
101 | |||
102 | private function findExistingRecords( IDatabase $db, array $neededRecords ): array { |
||
127 | |||
128 | private function insertNonExistingRecords( IDatabase $db, array $neededRecords ) { |
||
150 | |||
151 | private function filterNonExistingRecords( $neededRecords, $existingRecords ): array { |
||
170 | |||
171 | private function calcRecordHash( $record ) { |
||
175 | |||
176 | } |
||
177 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..