From 9d6f3cd8b8eff9998abb671b4c469980275d2ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 31 Jul 2023 11:54:32 +0000 Subject: [PATCH] Put back the lost bootstrap.php files and some fixes --- .gitignore | 1 + inc/class-helpers.php | 9 +++++---- loggers/class-media-logger.php | 4 ++-- loggers/class-plugin-acf-logger.php | 2 +- loggers/class-plugin-logger.php | 7 +++---- loggers/class-post-logger.php | 4 ++-- loggers/class-privacy-logger.php | 6 +++--- loggers/class-theme-logger.php | 14 +++++++------- loggers/class-user-logger.php | 10 +++++----- tests/phpstan/bootstrap.php | 11 +++++++++++ 10 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 tests/phpstan/bootstrap.php diff --git a/.gitignore b/.gitignore index 032c3fdb..1a5e17f3 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ tests/_data/* !tests/acceptance !tests/functional !tests/unit +!tests/phpstan !tests/wpunit !tests/_output tests/_output/* diff --git a/inc/class-helpers.php b/inc/class-helpers.php index e1520bc6..527d6587 100644 --- a/inc/class-helpers.php +++ b/inc/class-helpers.php @@ -395,10 +395,11 @@ function( $taxononomies_to_skip ) use ( $taxonomy_slug ) { * @since 2.0 * @since 3.3 Respects gravatar setting in discussion settings. * - * @param string $email email address - * @param int $size Size of the avatar image - * @param string $default URL to a default image to use if no avatar is available - * @param string $alt Alternative text to use in image tag. Defaults to blank + * @param string $email email address + * @param string $size Size of the avatar image + * @param string $default URL to a default image to use if no avatar is available + * @param string|false $alt Alternative text to use in image tag. Defaults to blank + * @param array $args Avatar arguments * @return string The img element for the user's avatar */ public static function get_avatar( $email, $size = '96', $default = '', $alt = false, $args = array() ) { diff --git a/loggers/class-media-logger.php b/loggers/class-media-logger.php index 36ee05fb..e1e4e496 100644 --- a/loggers/class-media-logger.php +++ b/loggers/class-media-logger.php @@ -62,8 +62,8 @@ public function loaded() { * * @since 2.0.21 * - * @param int $id ID of the new attachment. - * @param array $args An array of arguments to add the attachment. + * @param int $attachment_id ID of the new attachment. + * @param array $args An array of arguments to add the attachment. */ public function on_mw_new_media_object( $attachment_id, $args ) { $attachment_post = get_post( $attachment_id ); diff --git a/loggers/class-plugin-acf-logger.php b/loggers/class-plugin-acf-logger.php index 535c10a3..8085e1b0 100644 --- a/loggers/class-plugin-acf-logger.php +++ b/loggers/class-plugin-acf-logger.php @@ -152,7 +152,7 @@ public function prevent_second_acf_field_group_post_save_log( $ok_to_log, $new_s * * Called when ACF saves a post. * - * @param mixed int $post_id ID of post that is being saved. string "option" or "options" when saving an options page. + * @param mixed $post_id ID of post that is being saved. String "option" or "options" when saving an options page. */ public function on_acf_save_post( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { diff --git a/loggers/class-plugin-logger.php b/loggers/class-plugin-logger.php index 58dff5b8..6e9f4f70 100644 --- a/loggers/class-plugin-logger.php +++ b/loggers/class-plugin-logger.php @@ -690,10 +690,9 @@ public function remove_saved_versions() { * Called when plugins is updated or installed * Called from class-wp-upgrader.php * - * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might - * be a Theme_Upgrader or Core_Upgrade instance. - * @param array $data { - * Array of bulk item update data. + * @param Plugin_Upgrader $plugin_upgrader_instance Plugin_Upgrader instance. In other contexts, $this, might + * be a Theme_Upgrader or Core_Upgrade instance. + * @param array $arr_data Array of bulk item update data. */ public function on_upgrader_process_complete( $plugin_upgrader_instance, $arr_data ) { // Can't use get_plugins() here to get version of plugins updated from diff --git a/loggers/class-post-logger.php b/loggers/class-post-logger.php index 02dbb054..0cc7fbe0 100644 --- a/loggers/class-post-logger.php +++ b/loggers/class-post-logger.php @@ -357,7 +357,7 @@ public function on_untrash_post( $post_id ) { /** * Fired immediately before a post is deleted from the database. * - * @param int $postid Post ID. + * @param int $post_id Post ID. */ public function on_delete_post( $post_id ) { $post = get_post( $post_id ); @@ -452,7 +452,7 @@ public function get_skip_posttypes() { /** * Check if post type is ok to log by logger * - * @param Int or WP_Post $post Post the check. + * @param \WP_Post|int $post Post the check. * * @return bool */ diff --git a/loggers/class-privacy-logger.php b/loggers/class-privacy-logger.php index 717b43d3..b17cb1e8 100644 --- a/loggers/class-privacy-logger.php +++ b/loggers/class-privacy-logger.php @@ -228,9 +228,9 @@ public function on_user_request_action_confirmed( $request_id ) { * Used to catch data export request actions from screen at * /wp-admin/export-personal-data.php * - * @param int $post_ID Post ID. - * @param WP_Post $post Post object. - * @param bool $update Whether this is an existing post being updated or not. + * @param int $post_ID Post ID. + * @param \WP_Post $post Post object. + * @param bool $update Whether this is an existing post being updated or not. */ public function on_save_post_user_request( $post_ID, $post, $update ) { if ( empty( $post_ID ) ) { diff --git a/loggers/class-theme-logger.php b/loggers/class-theme-logger.php index 5a0039af..dcd5770c 100644 --- a/loggers/class-theme-logger.php +++ b/loggers/class-theme-logger.php @@ -178,8 +178,8 @@ public function on_action_deleted_theme( $stylesheet, $deleted ) { /** * Log theme updated. * - * @param WP_Upgrader $upgrader_instance WP_Upgrader instance. - * @param array $arr_data Array of bulk item update data. + * @param \WP_Upgrader $upgrader_instance WP_Upgrader instance. + * @param array $arr_data Array of bulk item update data. */ public function on_upgrader_process_complete_theme_update( $upgrader_instance = null, $arr_data = null ) { @@ -274,8 +274,8 @@ public function on_upgrader_process_complete_theme_update( $upgrader_instance = /** * Log theme installation. * - * @param WP_Upgrader $upgrader_instance WP_Upgrader instance. - * @param array $arr_data Array of bulk item update data. + * @param \WP_Upgrader $upgrader_instance WP_Upgrader instance. + * @param array $arr_data Array of bulk item update data. * @return void */ public function on_upgrader_process_complete_theme_install( $upgrader_instance = null, $arr_data = null ) { @@ -887,7 +887,7 @@ public function on_action_sidebar_admin_setup__detect_widget_delete() { * Get a sidebar by id * * @param string $sidebar_id ID of sidebar. - * @return sidebar info or false on failure. + * @return string|false sidebar info or false on failure. */ public function getSidebarById( $sidebar_id ) { @@ -912,8 +912,8 @@ public function getSidebarById( $sidebar_id ) { /** * Get an widget by id's id_base * - * @param string $id_base - * @return wp_widget object or false on failure + * @param string $widget_id_base + * @return \WP_Widget|false wp_widget object or false on failure */ public function getWidgetByIdBase( $widget_id_base ) { diff --git a/loggers/class-user-logger.php b/loggers/class-user-logger.php index 11765f77..1d8f316c 100644 --- a/loggers/class-user-logger.php +++ b/loggers/class-user-logger.php @@ -472,8 +472,8 @@ public function onRetrievePasswordMessage( $message, $key, $user_login, $user_da /** * Fired before the password reset procedure is validated. * - * @param object $errors WP Error object. - * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. + * @param \WP_Error $errors WP Error object. + * @param \WP_User|\WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. */ public function onValidatePasswordReset( $errors, $user ) { $context = array(); @@ -739,9 +739,9 @@ public function on_user_register( $user_id, $userdata = array() ) { /** * Log failed login attempt to username that exists * - * @param \WP_User|\WP_Error $user The WP_User object of the user being edited, - * or a WP_Error object if validation has already failed. - * @param string $password + * @param \WP_User|\WP_Error $userOrError The WP_User object of the user being edited, + * or a WP_Error object if validation has already failed. + * @param string $password */ public function onWpAuthenticateUser( $userOrError, $password ) { diff --git a/tests/phpstan/bootstrap.php b/tests/phpstan/bootstrap.php new file mode 100644 index 00000000..5cc00dea --- /dev/null +++ b/tests/phpstan/bootstrap.php @@ -0,0 +1,11 @@ +