1 | <?php |
||
51 | class mock_wpdb extends wpdb { |
||
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * Connects to the database server and selects a database |
||
57 | * |
||
58 | * PHP5 style constructor for compatibility with PHP5. Does |
||
59 | * the actual setting up of the class properties and connection |
||
60 | * to the database. |
||
61 | * |
||
62 | * @link https://core.trac.wordpress.org/ticket/3354 |
||
63 | * @since 2.0.8 |
||
64 | * |
||
65 | * @global string $wp_version The WordPress version string. |
||
66 | * |
||
67 | * @param string $dbuser MySQL database user |
||
|
|||
68 | * @param string $dbpassword MySQL database password |
||
69 | * @param string $dbname MySQL database name |
||
70 | * @param string $dbhost MySQL database host |
||
71 | */ |
||
72 | public function __construct() { |
||
75 | |||
76 | |||
77 | |||
78 | /** |
||
79 | * Change the current SQL mode, and ensure its WordPress compatibility. |
||
80 | * |
||
81 | * If no modes are passed, it will ensure the current MySQL server |
||
82 | * modes are compatible. |
||
83 | * |
||
84 | * @since 3.9.0 |
||
85 | * |
||
86 | * @param array $modes Optional. A list of SQL modes to set. |
||
87 | */ |
||
88 | public function set_sql_mode( $modes = array() ) { |
||
91 | |||
92 | |||
93 | |||
94 | /** |
||
95 | * Selects a database using the current database connection. |
||
96 | * |
||
97 | * The database name will be changed based on the current database |
||
98 | * connection. On failure, the execution will bail and display an DB error. |
||
99 | * |
||
100 | * @since 0.71 |
||
101 | * |
||
102 | * @param string $db MySQL database name |
||
103 | * @param resource|null $dbh Optional link identifier. |
||
104 | */ |
||
105 | public function select( $db, $dbh = null ) { |
||
108 | |||
109 | |||
110 | |||
111 | /** |
||
112 | * Real escape, using mysqli_real_escape_string() or mysql_real_escape_string() |
||
113 | * |
||
114 | * @see mysqli_real_escape_string() |
||
115 | * @see mysql_real_escape_string() |
||
116 | * @since 2.8.0 |
||
117 | * |
||
118 | * @param string $string to escape |
||
119 | * @return string escaped |
||
120 | */ |
||
121 | function _real_escape( $string ) { |
||
124 | |||
125 | /** |
||
126 | * Print SQL/DB error. |
||
127 | * |
||
128 | * @since 0.71 |
||
129 | * @global array $EZSQL_ERROR Stores error information of query and error string. |
||
130 | * |
||
131 | * @param string $str The error to display. |
||
132 | * @return void|false Void if the showing of errors is enabled, false if disabled. |
||
133 | */ |
||
134 | public function print_error( $str = '' ) { |
||
189 | |||
190 | /** |
||
191 | * Kill cached query results. |
||
192 | * |
||
193 | * @since 0.71 |
||
194 | */ |
||
195 | public function flush() { |
||
198 | |||
199 | /** |
||
200 | * Connect to and select database. |
||
201 | * |
||
202 | * If $allow_bail is false, the lack of database connection will need |
||
203 | * to be handled manually. |
||
204 | * |
||
205 | * @since 3.0.0 |
||
206 | * @since 3.9.0 $allow_bail parameter added. |
||
207 | * |
||
208 | * @param bool $allow_bail Optional. Allows the function to bail. Default true. |
||
209 | * @return bool True with a successful connection, false on failure. |
||
210 | */ |
||
211 | public function db_connect( $allow_bail = true ) { |
||
214 | |||
215 | /** |
||
216 | * Checks that the connection to the database is still up. If not, try to reconnect. |
||
217 | * |
||
218 | * If this function is unable to reconnect, it will forcibly die, or if after the |
||
219 | * the {@see 'template_redirect'} hook has been fired, return false instead. |
||
220 | * |
||
221 | * If $allow_bail is false, the lack of database connection will need |
||
222 | * to be handled manually. |
||
223 | * |
||
224 | * @since 3.9.0 |
||
225 | * |
||
226 | * @param bool $allow_bail Optional. Allows the function to bail. Default true. |
||
227 | * @return bool|void True if the connection is up. |
||
228 | */ |
||
229 | public function check_connection( $allow_bail = true ) { |
||
232 | |||
233 | /** |
||
234 | * Perform a MySQL database query, using current database connection. |
||
235 | * |
||
236 | * More information can be found on the codex page. |
||
237 | * |
||
238 | * @since 0.71 |
||
239 | * |
||
240 | * @param string $query Database query |
||
241 | * @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows |
||
242 | * affected/selected for all other queries. Boolean false on error. |
||
243 | */ |
||
244 | public function query( $query ) { |
||
247 | |||
248 | /** |
||
249 | * Retrieves the character set for the given column. |
||
250 | * |
||
251 | * @since 4.2.0 |
||
252 | * |
||
253 | * @param string $table Table name. |
||
254 | * @param string $column Column name. |
||
255 | * @return string|false|WP_Error Column character set as a string. False if the column has no |
||
256 | * character set. WP_Error object if there was an error. |
||
257 | */ |
||
258 | public function get_col_charset( $table, $column ) { |
||
261 | |||
262 | /** |
||
263 | * Load the column metadata from the last query. |
||
264 | * |
||
265 | * @since 3.5.0 |
||
266 | */ |
||
267 | protected function load_col_info() { |
||
272 | |||
273 | /** |
||
274 | * Wraps errors in a nice header and footer and dies. |
||
275 | * |
||
276 | * Will not die if wpdb::$show_errors is false. |
||
277 | * |
||
278 | * @since 1.5.0 |
||
279 | * |
||
280 | * @param string $message The error message. |
||
281 | * @param string $error_code Optional. A computer-readable string to identify the error. |
||
282 | * @return void|false Void if the showing of errors is enabled, false if disabled. |
||
283 | */ |
||
284 | public function bail( $message, $error_code = '500' ) { |
||
287 | |||
288 | |||
289 | /** |
||
290 | * Closes the current database connection. |
||
291 | * |
||
292 | * @since 4.5.0 |
||
293 | * |
||
294 | * @return bool True if the connection was successfully closed, false if it wasn't, |
||
295 | * or the connection doesn't exist. |
||
296 | */ |
||
297 | public function close() { |
||
300 | |||
301 | /** |
||
302 | * Determine if a database supports a particular feature. |
||
303 | * |
||
304 | * @since 2.7.0 |
||
305 | * @since 4.1.0 Added support for the 'utf8mb4' feature. |
||
306 | * @since 4.6.0 Added support for the 'utf8mb4_520' feature. |
||
307 | * |
||
308 | * @see wpdb::db_version() |
||
309 | * |
||
310 | * @param string $db_cap The feature to check for. Accepts 'collation', |
||
311 | * 'group_concat', 'subqueries', 'set_charset', |
||
312 | * 'utf8mb4', or 'utf8mb4_520'. |
||
313 | * @return int|false Whether the database feature is supported, false otherwise. |
||
314 | */ |
||
315 | public function has_cap( $db_cap ) { |
||
318 | |||
319 | |||
320 | /** |
||
321 | * Retrieves the MySQL server version. |
||
322 | * |
||
323 | * @since 2.7.0 |
||
324 | * |
||
325 | * @return null|string Null on failure, version number on success. |
||
326 | */ |
||
327 | public function db_version() { |
||
330 | } |
||
331 | |||
334 |
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.