From 66d06f5c26d7fa21e55fc73c431bcf887da78cbd Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 7 Sep 2023 02:19:43 +0000 Subject: [PATCH] fix: issues found by phpcs --- inc/class-datetimeutils.php | 4 ++-- inc/class-utils.php | 2 +- inc/class-webauthn-user.php | 1 + phpcs.xml.dist | 4 ++-- views/user-profile.php | 5 +++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/inc/class-datetimeutils.php b/inc/class-datetimeutils.php index 9eaae897..4710d2c7 100644 --- a/inc/class-datetimeutils.php +++ b/inc/class-datetimeutils.php @@ -3,13 +3,13 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; abstract class DateTimeUtils { - public static function format_date_time( int $dt ) : string { + public static function format_date_time( int $dt ): string { $date_format = (string) get_option( 'date_format', 'Y-m-d' ); $time_format = (string) get_option( 'time_format', 'H:i:s' ); return date_i18n( $date_format . ' ' . $time_format, $dt, true ); } - public static function format_date_time_full( int $dt ) : string { + public static function format_date_time_full( int $dt ): string { return gmdate( 'Y-m-d H:i:s', $dt ); } } diff --git a/inc/class-utils.php b/inc/class-utils.php index 9e0284b8..7d89a314 100644 --- a/inc/class-utils.php +++ b/inc/class-utils.php @@ -24,7 +24,7 @@ public static function get_u2f_app_id(): string { * @psalm-param array $params * @psalm-suppress PossiblyUnusedParam */ - public static function render( string $view, array $params = [] ): void { + public static function render( string $view, array $params = [] ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed /** @psalm-suppress UnresolvableInclude */ require __DIR__ . '/../views/' . $view . '.php'; // NOSONAR } diff --git a/inc/class-webauthn-user.php b/inc/class-webauthn-user.php index 8555d754..2ab87215 100644 --- a/inc/class-webauthn-user.php +++ b/inc/class-webauthn-user.php @@ -52,6 +52,7 @@ public function generate_and_save_handle(): UserHandle { ); if ( false === $result ) { + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escape when printing throw new UnexpectedValueException( __( 'Unable to save the user handle to the database.', 'two-factor-provider-webauthn' ) ); } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 538fe21b..00bace7a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -20,8 +20,8 @@ - - + + diff --git a/views/user-profile.php b/views/user-profile.php index e44ca458..0243bd19 100644 --- a/views/user-profile.php +++ b/views/user-profile.php @@ -2,9 +2,10 @@ use WildWolf\WordPress\TwoFactorWebAuthn\Key_Table; -/** @psalm-var array{user: WP_User} $params */ +defined( 'ABSPATH' ) || die(); -defined( 'ABSPATH' ) || die(); ?> +/** @psalm-var array{user: WP_User} $params */ +?>