1 | <?php |
||
34 | abstract class AbstractBaseProcessor extends AbstractProcessor |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * The array with the statements to be prepared. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $statements = array(); |
||
43 | |||
44 | /** |
||
45 | * The array with the prepared statements. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $preparedStatements = array(); |
||
50 | |||
51 | /** |
||
52 | * The default statement name. |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $defaultStatementName; |
||
57 | |||
58 | /** |
||
59 | * Return's the array with the SQL statements that has to be prepared. |
||
60 | * |
||
61 | * @return array The SQL statements to be prepared |
||
62 | */ |
||
63 | protected function getStatements() |
||
67 | |||
68 | /** |
||
69 | * Add's the prepared statement. |
||
70 | * |
||
71 | * @param string $name The unique name of the prepared statement |
||
72 | * @param \PDOStatement $preparedStatement The prepared statement |
||
73 | * |
||
74 | * @return void |
||
75 | */ |
||
76 | protected function addPreparedStatement($name, \PDOStatement $preparedStatement) |
||
80 | |||
81 | /** |
||
82 | * Return's the prepared statement with the passed name or the default one. |
||
83 | * |
||
84 | * @param string|null $name The name of the prepared statement to return |
||
85 | * @param string|null $defaultName The name of the default prepared statement |
||
86 | * |
||
87 | * @return \PDOStatement The prepared statement |
||
88 | */ |
||
89 | protected function getPreparedStatement($name = null, $defaultName = null) |
||
100 | |||
101 | /** |
||
102 | * Qeuery whether or not the prepared statement is available or not. |
||
103 | * |
||
104 | * @param string $name The nqme of the prepared statement |
||
105 | * |
||
106 | * @return boolean TRUE if the prepared statement is available, else FALSE |
||
107 | */ |
||
108 | protected function hasPreparedStatement($name) |
||
112 | |||
113 | /** |
||
114 | * The array with the prepared statements. |
||
115 | * |
||
116 | * @return array The prepared statments |
||
117 | */ |
||
118 | protected function getPreparedStatements() |
||
122 | |||
123 | /** |
||
124 | * Prepare's and return's the passed row by removing the |
||
125 | * entity status. |
||
126 | * |
||
127 | * @param array $row The row to prepare |
||
128 | * |
||
129 | * @return array The prepared row |
||
130 | */ |
||
131 | protected function prepareRow(array $row) |
||
140 | |||
141 | /** |
||
142 | * Return's the name of the processor's default statement. |
||
143 | * |
||
144 | * @return string The statement name |
||
145 | */ |
||
146 | public function getDefaultStatementName() |
||
150 | |||
151 | /** |
||
152 | * Implements the CRUD functionality the processor is responsible for, |
||
153 | * can be one of CREATE, READ, UPDATE or DELETE a entity. |
||
154 | * |
||
155 | * @param array $row The row to persist |
||
156 | * @param string|null $name The name of the prepared statement that has to be executed |
||
157 | * @param string|null $primaryKeyMemberName The primary key member name of the entity to use |
||
158 | * |
||
159 | * @return void |
||
160 | */ |
||
161 | public function execute($row, $name = null, $primaryKeyMemberName = null) |
||
182 | |||
183 | /** |
||
184 | * Initializes the proceessor with the prepared statements. |
||
185 | * |
||
186 | * @return void |
||
187 | */ |
||
188 | public function init() |
||
201 | |||
202 | /** |
||
203 | * Returns the first key of the passed array. |
||
204 | * |
||
205 | * This method has been used instead of the PHP function array_key_first, because |
||
206 | * this function will be available with PHP >= 7.3.0. |
||
207 | * |
||
208 | * @param array $array The array to return the first key for |
||
209 | * |
||
210 | * @return mixed|NULL The first key or NULL |
||
211 | * @link https://www.php.net/array_key_first |
||
212 | */ |
||
213 | private function firstKey(array $array) |
||
227 | } |
||
228 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.