Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors reported by PHPStan #619

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ public static function current_user_can_update_two_factor_options( $context = 'd
* Return a falsey value (false, 0) if you wish to never require revalidation.
*
* @param int $two_factor_revalidate_time The grace time between last validation time and when it'll be accepted. Default 10 minutes (in seconds).
* @param int $user_id The user ID.
* @param string $context The context in use, 'display' or 'save'. Save has twice the grace time.
*/
$two_factor_revalidate_time = apply_filters( 'two_factor_revalidate_time', 10 * MINUTE_IN_SECONDS, $user_id, $context );
Expand Down
2 changes: 1 addition & 1 deletion providers/class-two-factor-backup-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function __construct() {
add_action( 'two_factor_user_options_' . __CLASS__, array( $this, 'user_options' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );

return parent::__construct();
parent::__construct();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion providers/class-two-factor-dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Two_Factor_Dummy extends Two_Factor_Provider {
*/
protected function __construct() {
add_action( 'two_factor_user_options_' . __CLASS__, array( $this, 'user_options' ) );
return parent::__construct();
parent::__construct();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion providers/class-two-factor-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Two_Factor_Email extends Two_Factor_Provider {
*/
protected function __construct() {
add_action( 'two_factor_user_options_' . __CLASS__, array( $this, 'user_options' ) );
return parent::__construct();
parent::__construct();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions providers/class-two-factor-fido-u2f-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public static function show_user_profile( $user ) {
* @static
*
* @param int $user_id User ID.
* @return false
* @return void|never
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dubious.
catch should do better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is pending removal via #439 so not too much effort needs to happen here :)

*/
public static function catch_submission( $user_id ) {
if ( ! empty( $_REQUEST['do_new_security_key'] ) ) {
Expand All @@ -243,7 +243,7 @@ public static function catch_submission( $user_id ) {

Two_Factor_FIDO_U2F::add_security_key( $user_id, $reg );
} catch ( Exception $e ) {
return false;
return;
}

delete_user_meta( $user_id, self::REGISTER_DATA_USER_META_KEY );
Expand Down
6 changes: 3 additions & 3 deletions providers/class-two-factor-fido-u2f.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function __construct() {

add_action( 'two_factor_user_options_' . __CLASS__, array( $this, 'user_options' ) );

return parent::__construct();
parent::__construct();
}

/**
Expand Down Expand Up @@ -143,7 +143,7 @@ public static function enqueue_scripts() {
* @since 0.1-dev
*
* @param WP_User $user WP_User object of the logged-in user.
* @return null
* @return void
*/
public function authentication_page( $user ) {
require_once ABSPATH . '/wp-admin/includes/template.php';
Expand All @@ -165,7 +165,7 @@ public function authentication_page( $user ) {
?>
<p><?php esc_html_e( 'An error occurred while creating authentication data.', 'two-factor' ); ?></p>
<?php
return null;
return;
}

wp_localize_script(
Expand Down
14 changes: 7 additions & 7 deletions providers/class-two-factor-totp.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) );
add_action( 'two_factor_user_options_' . __CLASS__, array( $this, 'user_two_factor_options' ) );

return parent::__construct();
parent::__construct();
}

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ public function enqueue_assets( $hook_suffix ) {
/**
* Rest API endpoint for handling deactivation of TOTP.
*
* @param WP_Rest_Request $request The Rest Request object.
* @param WP_REST_Request $request The Rest Request object.
* @return array Success array.
*/
public function rest_delete_totp( $request ) {
Expand All @@ -164,7 +164,7 @@ public function rest_delete_totp( $request ) {
/**
* REST API endpoint for setting up TOTP.
*
* @param WP_Rest_Request $request The Rest Request object.
* @param WP_REST_Request $request The Rest Request object.
* @return WP_Error|array Array of data on success, WP_Error on error.
*/
public function rest_setup_totp( $request ) {
Expand Down Expand Up @@ -203,8 +203,8 @@ public function rest_setup_totp( $request ) {
/**
* Generates a URL that can be used to create a QR code.
*
* @param WP_User $user The user to generate a URL for.
* @param string $key The secret key.
* @param WP_User $user The user to generate a URL for.
* @param string $secret_key The secret key.
*
* @return string
*/
Expand Down Expand Up @@ -260,13 +260,13 @@ public static function generate_qr_code_url( $user, $secret_key ) {
* Display TOTP options on the user settings page.
*
* @param WP_User $user The current user being edited.
* @return false
* @return void
*
* @codeCoverageIgnore
*/
public function user_two_factor_options( $user ) {
if ( ! isset( $user->ID ) ) {
return false;
return;
}

$key = $this->get_user_totp_key( $user->ID );
Expand Down
Loading