diff --git a/.tests/php/integration/AAAMainTest.php b/.tests/php/integration/AAAMainTest.php
index 8d299104..3cfeab59 100644
--- a/.tests/php/integration/AAAMainTest.php
+++ b/.tests/php/integration/AAAMainTest.php
@@ -67,7 +67,7 @@ class AAAMainTest extends HCaptchaWPTestCase {
*
* @throws ReflectionException ReflectionException.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
$hcaptcha = hcaptcha();
$loaded_classes = $this->get_protected_property( $hcaptcha, 'loaded_classes' );
@@ -105,7 +105,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @return void
*/
- public function test_init() {
+ public function test_init(): void {
$hcaptcha = hcaptcha();
// The plugin was loaded by codeception.
@@ -133,7 +133,7 @@ public function test_init() {
* @noinspection PhpUnitTestsInspection
* @noinspection UnusedFunctionResultInspection
*/
- public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_when_logged_in, $whitelisted, bool $hcaptcha_active ) {
+ public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_when_logged_in, $whitelisted, bool $hcaptcha_active ): void {
global $current_user;
$hcaptcha = hcaptcha();
@@ -256,7 +256,7 @@ public function test_init_and_init_hooks_on_elementor_pro_edit_page(
array $get,
array $post,
bool $hcaptcha_active
- ) {
+ ): void {
global $current_user;
add_filter(
@@ -368,7 +368,7 @@ public function dp_test_init_and_init_hooks_on_elementor_pro_edit_page(): array
*
* @throws ReflectionException ReflectionException.
*/
- public function test_init_and_init_hooks_on_xml_rpc_request() {
+ public function test_init_and_init_hooks_on_xml_rpc_request(): void {
$subject = Mockery::mock( Main::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods()->shouldReceive( 'is_xml_rpc' )->andReturn( true );
@@ -389,7 +389,7 @@ public function test_init_and_init_hooks_on_xml_rpc_request() {
/**
* Test prefetch_hcaptcha_dns().
*/
- public function test_prefetch_hcaptcha_dns() {
+ public function test_prefetch_hcaptcha_dns(): void {
$urls = [
'//s.w.org',
];
@@ -409,7 +409,7 @@ public function test_prefetch_hcaptcha_dns() {
*
* @return void
*/
- public function test_csp_headers() {
+ public function test_csp_headers(): void {
$headers = [
'some_header' => 'some header content',
];
@@ -457,7 +457,7 @@ static function ( $add, $h ) use ( &$headers ) {
* @dataProvider dp_test_print_inline_styles
* @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles( $custom_themes ) {
+ public function test_print_inline_styles( $custom_themes ): void {
$license = 'pro';
$bg = '#f0f0f0';
$config_params = 'on' === $custom_themes
@@ -614,7 +614,7 @@ public function dp_test_print_inline_styles(): array {
* Test login_head().
*
* @noinspection CssUnusedSymbol*/
- public function test_login_head() {
+ public function test_login_head(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
@@ -664,7 +664,7 @@ static function ( $name ) {
* @return void
* @dataProvider dp_test_get_api_url
*/
- public function test_get_api_url( string $api_host, string $expected ) {
+ public function test_get_api_url( string $api_host, string $expected ): void {
update_option(
'hcaptcha_settings',
[
@@ -699,7 +699,7 @@ public function dp_test_get_api_url(): array {
*
* @return void
*/
- public function test_get_api_src() {
+ public function test_get_api_src(): void {
update_option(
'hcaptcha_settings',
[
@@ -733,7 +733,7 @@ public function test_get_api_src() {
* @return void
* @dataProvider dp_test_get_verify_url
*/
- public function test_get_verify_url( string $backend, string $expected ) {
+ public function test_get_verify_url( string $backend, string $expected ): void {
update_option(
'hcaptcha_settings',
[
@@ -772,7 +772,7 @@ public function dp_test_get_verify_url(): array {
* @return void
* @dataProvider dp_test_get_check_site_config_url
*/
- public function test_get_check_site_config_url( string $backend, string $expected ) {
+ public function test_get_check_site_config_url( string $backend, string $expected ): void {
update_option(
'hcaptcha_settings',
[
@@ -814,7 +814,7 @@ public function dp_test_get_check_site_config_url(): array {
* @throws ReflectionException ReflectionException.
* @noinspection BadExpressionStatementJS
*/
- public function test_print_footer_scripts( $compat, $language, $custom_themes, string $expected_script_src ) {
+ public function test_print_footer_scripts( $compat, $language, $custom_themes, string $expected_script_src ): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
@@ -984,7 +984,7 @@ function delayedLoad() {
*
* @return void
*/
- public function test_print_footer_script_when_blocked_by_filter() {
+ public function test_print_footer_script_when_blocked_by_filter(): void {
add_filter( 'hcap_activate', '__return_true' );
add_filter( 'hcap_print_hcaptcha_scripts', '__return_false' );
@@ -1058,7 +1058,7 @@ public function dp_test_print_footer_scripts(): array {
* @dataProvider dp_test_whitelist_ip
* @return void
*/
- public function test_whitelist_ip( $whitelisted_ips, $client_ip, bool $expected ) {
+ public function test_whitelist_ip( $whitelisted_ips, $client_ip, bool $expected ): void {
update_option( 'hcaptcha_settings', [ 'whitelisted_ips' => $whitelisted_ips ] );
$subject = new Main();
@@ -1087,7 +1087,7 @@ public function dp_test_whitelist_ip(): array {
/**
* Test print_footer_scripts() when form NOT shown.
*/
- public function test_print_footer_scripts_when_form_NOT_shown() {
+ public function test_print_footer_scripts_when_form_NOT_shown(): void {
self::assertFalse( wp_script_is( 'hcaptcha' ) );
$site_key = 'some key';
@@ -1116,8 +1116,8 @@ public function test_print_footer_scripts_when_form_NOT_shown() {
* @dataProvider dp_test_load_modules
* @throws ReflectionException ReflectionException.
*/
- public function test_load_modules( array $module ) {
- list( $option_name, $option_value ) = $module[0];
+ public function test_load_modules( array $module ): void {
+ [ $option_name, $option_value ] = $module[0];
update_option(
'hcaptcha_settings',
@@ -1668,7 +1668,7 @@ static function ( &$value ) {
/**
* Test load_textdomain().
*/
- public function test_load_textdomain() {
+ public function test_load_textdomain(): void {
$subject = new Main();
$subject->init_hooks();
@@ -1721,7 +1721,7 @@ private function normalize_path( $path ) {
*
* @param array $component Component.
*/
- public function check_component_loaded( array $component ) {
+ public function check_component_loaded( array $component ): void {
$intersect = array_intersect( $component, $this->normalize_path( get_included_files() ) );
$included = array_intersect( $component, self::$included_components );
self::assertSame( $included, $intersect );
diff --git a/.tests/php/integration/ACFE/FormTest.php b/.tests/php/integration/ACFE/FormTest.php
index 0484b886..143d1900 100644
--- a/.tests/php/integration/ACFE/FormTest.php
+++ b/.tests/php/integration/ACFE/FormTest.php
@@ -29,7 +29,7 @@ class FormTest extends HCaptchaWPTestCase {
/**
* Tear down the test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST['_acf_post_id'], $_POST[ HCaptcha::HCAPTCHA_WIDGET_ID ] );
wp_dequeue_script( 'hcaptcha' );
@@ -44,7 +44,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test init_hooks().
*/
- public function test_init_hooks() {
+ public function test_init_hooks(): void {
$subject = new Form();
self::assertSame( 10, has_action( 'acfe/form/render/before_fields', [ $subject, 'before_fields' ] ) );
@@ -61,7 +61,7 @@ public function test_init_hooks() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_before_fields() {
+ public function test_before_fields(): void {
$id = 5;
$subject = new Form();
@@ -82,7 +82,7 @@ public function test_before_fields() {
* @dataProvider dp_test_remove_recaptcha_render
* @noinspection UnusedFunctionResultInspection
*/
- public function test_remove_recaptcha_render( array $field, $expected ) {
+ public function test_remove_recaptcha_render( array $field, $expected ): void {
$recaptcha = Mockery::mock( 'acfe_field_recaptcha' );
$recaptcha->shouldReceive( 'render_field' );
@@ -126,7 +126,7 @@ public function dp_test_remove_recaptcha_render(): array {
* @return void
* @dataProvider dp_test_add_hcaptcha
*/
- public function test_add_hcaptcha( array $field, string $expected ) {
+ public function test_add_hcaptcha( array $field, string $expected ): void {
$subject = new Form();
hcaptcha()->init_hooks();
@@ -176,7 +176,7 @@ public function dp_test_add_hcaptcha(): array {
* @return void
* @noinspection UnusedFunctionResultInspection
*/
- public function test_remove_recaptcha_verify() {
+ public function test_remove_recaptcha_verify(): void {
$value = 'some value';
$field = [ 'type' => 'some' ];
$input = 'some_input_name';
@@ -207,7 +207,7 @@ public function test_remove_recaptcha_verify() {
* @dataProvider dp_test_verify
* @throws ReflectionException ReflectionException.
*/
- public function test_verify( bool $result, bool $expected ) {
+ public function test_verify( bool $result, bool $expected ): void {
$valid = ! $expected;
$value = 'some hcaptcha response';
$input = 'some_input_name';
@@ -242,7 +242,7 @@ public function dp_test_verify(): array {
*
* @return void
*/
- public function test_verify_when_NOT_required() {
+ public function test_verify_when_NOT_required(): void {
$value = 'some hcaptcha response';
$input = 'some_input_name';
$field = [ 'required' => false ];
@@ -259,7 +259,7 @@ public function test_verify_when_NOT_required() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_verify_ajax() {
+ public function test_verify_ajax(): void {
$value = 'some hcaptcha response';
$input = 'some_input_name';
$field = [ 'required' => true ];
@@ -279,7 +279,7 @@ public function test_verify_ajax() {
/**
* Test enqueue_scripts().
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
$field = [
'type' => 'acfe_recaptcha',
'key' => 'some-key',
diff --git a/.tests/php/integration/Admin/Events/EventsTest.php b/.tests/php/integration/Admin/Events/EventsTest.php
index 1e334549..ab99bb91 100644
--- a/.tests/php/integration/Admin/Events/EventsTest.php
+++ b/.tests/php/integration/Admin/Events/EventsTest.php
@@ -29,7 +29,7 @@ class EventsTest extends HCaptchaWPTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_TRUE_CLIENT_IP'] );
$this->drop_table();
@@ -42,7 +42,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @return void
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
update_option( 'hcaptcha_settings', [ 'statistics' => [ 'on' ] ] );
hcaptcha()->init_hooks();
@@ -60,7 +60,7 @@ public function test_constructor_and_init_hooks() {
*
* @return void
*/
- public function test_save_event() {
+ public function test_save_event(): void {
global $wpdb;
$result = 'empty';
@@ -94,7 +94,7 @@ public function test_save_event() {
// Query the database to check if the event was saved.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $event = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}$table_name ORDER BY id DESC LIMIT 1" );
+ $event = $wpdb->get_row( "SELECT * FROM $wpdb->prefix$table_name ORDER BY id DESC LIMIT 1" );
// Check that the event data matches the test data.
// phpcs:disable WordPress.WP.AlternativeFunctions.json_encode_json_encode
@@ -112,7 +112,7 @@ public function test_save_event() {
*
* @return void
*/
- public function test_save_event_with_wrong_params() {
+ public function test_save_event_with_wrong_params(): void {
$subject = new Events();
@@ -126,7 +126,7 @@ public function test_save_event_with_wrong_params() {
*
* @return void
*/
- public function test_save_event_from_check_config() {
+ public function test_save_event_from_check_config(): void {
$subject = new Events();
@@ -151,7 +151,7 @@ public function test_save_event_from_check_config() {
*
* @return void
*/
- public function test_get_events() {
+ public function test_get_events(): void {
$date = wp_date( 'Y-m-d H:i:s' );
$expected = [
@@ -208,7 +208,7 @@ public function test_get_events() {
*
* @return void
*/
- public function test_get_forms() {
+ public function test_get_forms(): void {
$date = wp_date( 'Y-m-d H:i:s' );
$expected = [
@@ -261,7 +261,7 @@ public function test_get_forms() {
*
* @return void
*/
- public function test_create_table() {
+ public function test_create_table(): void {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
@@ -294,7 +294,7 @@ public function test_create_table() {
*
* @return void
*/
- public function test_get_where_date_gmt() {
+ public function test_get_where_date_gmt(): void {
$dates = [ '2024-05-01', '2024-05-02' ];
$expected = "date_gmt BETWEEN '2024-05-01 00:00:00' AND '2024-05-02 23:59:59'";
@@ -315,12 +315,12 @@ public function test_get_where_date_gmt() {
*
* @return void
*/
- private function drop_table() {
+ private function drop_table(): void {
global $wpdb;
$table_name = Events::TABLE_NAME;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$table_name" );
+ $wpdb->query( "DROP TABLE IF EXISTS $wpdb->prefix$table_name" );
}
}
diff --git a/.tests/php/integration/Admin/NotificationsTest.php b/.tests/php/integration/Admin/NotificationsTest.php
index 2fb363d8..d0be5f80 100644
--- a/.tests/php/integration/Admin/NotificationsTest.php
+++ b/.tests/php/integration/Admin/NotificationsTest.php
@@ -29,7 +29,7 @@ class NotificationsTest extends HCaptchaWPTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_REQUEST['action'], $_REQUEST['nonce'] );
parent::tearDown();
@@ -38,7 +38,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test init() and init_hooks().
*/
- public function test_init_and_init_hooks() {
+ public function test_init_and_init_hooks(): void {
$subject = new Notifications();
$subject->init();
@@ -76,7 +76,7 @@ public function test_init_and_init_hooks() {
* @dataProvider dp_test_get_notifications
* @return void
*/
- public function test_get_notifications( bool $empty_keys, bool $pro, bool $force ) {
+ public function test_get_notifications( bool $empty_keys, bool $pro, bool $force ): void {
global $current_user;
$user_id = 1;
@@ -244,7 +244,7 @@ public function dp_test_get_notifications(): array {
* @noinspection UnusedFunctionResultInspection
* @noinspection HtmlUnknownAttribute
*/
- public function test_show() {
+ public function test_show(): void {
global $current_user;
unset( $current_user );
@@ -463,7 +463,7 @@ class="button button-primary" target="_blank">
* @return void
* @noinspection UnusedFunctionResultInspection
*/
- public function test_show_without_notifications() {
+ public function test_show_without_notifications(): void {
global $current_user;
$user_id = 1;
@@ -490,7 +490,7 @@ public function test_show_without_notifications() {
*
* @return void
*/
- public function test_admin_enqueue_scripts() {
+ public function test_admin_enqueue_scripts(): void {
$params = [
'ajaxUrl' => 'http://test.test/wp-admin/admin-ajax.php',
'dismissNotificationAction' => Notifications::DISMISS_NOTIFICATION_ACTION,
@@ -528,7 +528,7 @@ public function test_admin_enqueue_scripts() {
*
* @return void
*/
- public function test_dismiss_notification() {
+ public function test_dismiss_notification(): void {
$user_id = 1;
wp_set_current_user( $user_id );
@@ -575,7 +575,7 @@ static function () use ( &$die_arr ) {
*
* @return void
*/
- public function test_dismiss_notification_with_bad_ajax_referer() {
+ public function test_dismiss_notification_with_bad_ajax_referer(): void {
$die_arr = [];
$expected = [
'',
@@ -614,7 +614,7 @@ static function () use ( &$die_arr ) {
*
* @return void
*/
- public function test_dismiss_notification_when_user_has_no_caps() {
+ public function test_dismiss_notification_when_user_has_no_caps(): void {
$action = Notifications::DISMISS_NOTIFICATION_ACTION;
$nonce = wp_create_nonce( $action );
@@ -659,7 +659,7 @@ static function () use ( &$die_arr ) {
*
* @return void
*/
- public function test_dismiss_notification_when_update_error() {
+ public function test_dismiss_notification_when_update_error(): void {
$user_id = 1;
wp_set_current_user( $user_id );
@@ -746,7 +746,7 @@ static function () use ( &$die_arr ) {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_reset_notifications() {
+ public function test_reset_notifications(): void {
$die_arr = [];
$expected = [
'',
@@ -852,7 +852,7 @@ static function () use ( &$die_arr ) {
*
* @return void
*/
- public function test_make_key_first() {
+ public function test_make_key_first(): void {
$subject = Mockery::mock( Notifications::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
diff --git a/.tests/php/integration/AutoVerify/AutoVerifyTest.php b/.tests/php/integration/AutoVerify/AutoVerifyTest.php
index fa0ed918..07e1b05d 100644
--- a/.tests/php/integration/AutoVerify/AutoVerifyTest.php
+++ b/.tests/php/integration/AutoVerify/AutoVerifyTest.php
@@ -26,7 +26,7 @@ class AutoVerifyTest extends HCaptchaWPTestCase {
/**
* Tear down test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_SERVER['REQUEST_METHOD'], $GLOBALS['current_screen'] );
delete_transient( AutoVerify::TRANSIENT );
@@ -36,7 +36,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test init() and init_hooks().
*/
- public function test_init_and_init_hooks() {
+ public function test_init_and_init_hooks(): void {
$subject = new AutoVerify();
$subject->init();
@@ -52,7 +52,7 @@ public function test_init_and_init_hooks() {
/**
* Test content_filter().
*/
- public function test_content_filter() {
+ public function test_content_filter(): void {
$request_uri = $this->get_test_request_uri();
$content = $this->get_test_content();
@@ -70,7 +70,7 @@ public function test_content_filter() {
/**
* Test widget_block_content_filter().
*/
- public function test_widget_block_content_filter() {
+ public function test_widget_block_content_filter(): void {
$wp_widget_block = Mockery::mock( 'WP_Widget_Block' );
$request_uri = $this->get_test_request_uri();
@@ -90,7 +90,7 @@ public function test_widget_block_content_filter() {
/**
* Test content_filter() with action containing host.
*/
- public function test_content_filter_with_action() {
+ public function test_content_filter_with_action(): void {
$request_uri = $this->get_test_request_uri();
$content = $this->get_test_content();
$content = str_replace(
@@ -113,7 +113,7 @@ public function test_content_filter_with_action() {
/**
* Test content_filter() when form action cannot be determined.
*/
- public function test_content_filter_without_form_action() {
+ public function test_content_filter_without_form_action(): void {
$content = $this->get_test_content();
unset( $_SERVER['REQUEST_URI'] );
@@ -128,7 +128,7 @@ public function test_content_filter_without_form_action() {
/**
* Test content_filter() when no input in form (really?).
*/
- public function test_content_filter_without_form_inputs() {
+ public function test_content_filter_without_form_inputs(): void {
$request_uri = wp_parse_url( $this->get_test_request_uri(), PHP_URL_PATH );
$content = $this->get_test_content();
$content = preg_replace( '##', '', $content );
@@ -152,7 +152,7 @@ public function test_content_filter_without_form_inputs() {
/**
* Test content_filter() when no data-auto in form (really?).
*/
- public function test_content_filter_without_form_data_auto() {
+ public function test_content_filter_without_form_data_auto(): void {
$request_uri = $this->get_test_request_uri();
$content = $this->get_test_content();
$content = preg_replace( '#data-auto=".*?">#', '', $content );
@@ -179,7 +179,7 @@ public function test_content_filter_without_form_data_auto() {
/**
* Test content_filter() in admin.
*/
- public function test_content_filter_in_admin() {
+ public function test_content_filter_in_admin(): void {
set_current_screen( 'some-screen' );
$content = $this->get_test_content();
@@ -194,7 +194,7 @@ public function test_content_filter_in_admin() {
/**
* Test content_filter() in ajax.
*/
- public function test_content_filter_in_ajax() {
+ public function test_content_filter_in_ajax(): void {
$content = $this->get_test_content();
$subject = new AutoVerify();
@@ -214,7 +214,7 @@ static function () {
/**
* Test verify_form() when not POST request.
*/
- public function test_verify_form_when_not_post() {
+ public function test_verify_form_when_not_post(): void {
$subject = new AutoVerify();
$subject->verify_form();
@@ -225,7 +225,7 @@ public function test_verify_form_when_not_post() {
/**
* Test verify_form() when no $_SERVER['REQUEST_URI'] defined.
*/
- public function test_verify_form_when_no_request_uri() {
+ public function test_verify_form_when_no_request_uri(): void {
$_SERVER['REQUEST_METHOD'] = 'POST';
unset( $_SERVER['REQUEST_URI'] );
@@ -237,7 +237,7 @@ public function test_verify_form_when_no_request_uri() {
/**
* Test verify_form() when no forms are registered.
*/
- public function test_verify_form_when_no_forms_are_registered() {
+ public function test_verify_form_when_no_forms_are_registered(): void {
$request_uri = $this->get_test_request_uri();
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -250,7 +250,7 @@ public function test_verify_form_when_no_forms_are_registered() {
/**
* Test verify_form() when forms on another uri are registered.
*/
- public function test_verify_form_when_forms_on_another_uri_are_registered() {
+ public function test_verify_form_when_forms_on_another_uri_are_registered(): void {
$request_uri = $this->get_test_request_uri();
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -267,9 +267,9 @@ public function test_verify_form_when_forms_on_another_uri_are_registered() {
}
/**
- * Test verify_form() when another forms on the same uri are registered.
+ * Test verify_form() when other forms on the same uri are registered.
*/
- public function test_verify_form_when_another_forms_on_the_same_uri_are_registered() {
+ public function test_verify_form_when_other_forms_on_the_same_uri_are_registered(): void {
$request_uri = $this->get_test_request_uri();
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -290,7 +290,7 @@ public function test_verify_form_when_another_forms_on_the_same_uri_are_register
*
* @noinspection PhpUnusedParameterInspection
*/
- public function test_verify_form_when_no_success() {
+ public function test_verify_form_when_no_success(): void {
$request_uri = $this->get_test_request_uri();
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -330,7 +330,7 @@ static function ( $name ) use ( &$die_arr ) {
/**
* Test verify_form() when verify is successful.
*/
- public function test_verify_form_when_success() {
+ public function test_verify_form_when_success(): void {
$request_uri = $this->get_test_request_uri();
$hcaptcha_response = 'some response';
$expected = [
@@ -360,7 +360,7 @@ public function test_verify_form_when_success() {
/**
* Test verify_form() in admin.
*/
- public function test_verify_form_in_admin() {
+ public function test_verify_form_in_admin(): void {
set_current_screen( 'some-screen' );
$subject = new AutoVerify();
@@ -370,7 +370,7 @@ public function test_verify_form_in_admin() {
/**
* Test verify_form() in ajax.
*/
- public function test_verify_form_in_ajax() {
+ public function test_verify_form_in_ajax(): void {
add_filter(
'wp_doing_ajax',
static function () {
@@ -385,7 +385,7 @@ static function () {
/**
* Test verify_form() in rest, case 3 and 4.
*/
- public function test_verify_form_in_rest_case_3_and_4() {
+ public function test_verify_form_in_rest_case_3_and_4(): void {
$old_wp_rewrite = $GLOBALS['wp_rewrite'];
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
diff --git a/.tests/php/integration/Avada/FormTest.php b/.tests/php/integration/Avada/FormTest.php
index ea335ffa..b7947231 100644
--- a/.tests/php/integration/Avada/FormTest.php
+++ b/.tests/php/integration/Avada/FormTest.php
@@ -27,7 +27,7 @@ class FormTest extends HCaptchaWPTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST['formData'], $_POST['hcaptcha-widget-id'] );
parent::tearDown();
@@ -38,7 +38,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @return void
*/
- public function test_init_hooks() {
+ public function test_init_hooks(): void {
$subject = new Form();
self::assertSame( 10, has_action( 'fusion_form_after_open', [ $subject, 'form_after_open' ] ) );
@@ -51,7 +51,7 @@ public function test_init_hooks() {
*
* @return void
*/
- public function test_add_hcaptcha() {
+ public function test_add_hcaptcha(): void {
$form_id = 5;
$args = [
'id' =>
@@ -79,7 +79,7 @@ public function test_add_hcaptcha() {
* @return void
* @noinspection PhpConditionAlreadyCheckedInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$demo_mode = true;
$hcaptcha_response = 'some_response';
$form_data = "h-captcha-response=$hcaptcha_response";
@@ -97,8 +97,9 @@ public function test_verify() {
* Test verify() when not verified.
*
* @return void
+ * @noinspection PhpUnusedParameterInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$hcaptcha_response = 'some_response';
$die_arr = [];
$expected = [
diff --git a/.tests/php/integration/BBPress/NewTopicTest.php b/.tests/php/integration/BBPress/NewTopicTest.php
index dc75fcc1..e5d8e240 100644
--- a/.tests/php/integration/BBPress/NewTopicTest.php
+++ b/.tests/php/integration/BBPress/NewTopicTest.php
@@ -35,7 +35,7 @@ class NewTopicTest extends HCaptchaPluginWPTestCase {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
unset( $_POST );
bbpress()->errors = new WP_Error();
@@ -46,7 +46,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'action' => 'hcaptcha_bbp_new_topic',
'name' => 'hcaptcha_bbp_new_topic_nonce',
@@ -72,7 +72,7 @@ public function test_add_captcha() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_bbp_new_topic_nonce', 'hcaptcha_bbp_new_topic' );
$expected = new WP_Error();
@@ -88,7 +88,7 @@ public function test_verify() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$expected = new WP_Error( 'hcap_error', 'Please complete the hCaptcha.' );
$subject = new NewTopic();
diff --git a/.tests/php/integration/BBPress/ReplyTest.php b/.tests/php/integration/BBPress/ReplyTest.php
index 83ce7a67..12419fde 100644
--- a/.tests/php/integration/BBPress/ReplyTest.php
+++ b/.tests/php/integration/BBPress/ReplyTest.php
@@ -35,7 +35,7 @@ class ReplyTest extends HCaptchaPluginWPTestCase {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
unset( $_POST );
bbpress()->errors = new WP_Error();
@@ -46,7 +46,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'action' => 'hcaptcha_bbp_reply',
'name' => 'hcaptcha_bbp_reply_nonce',
@@ -71,7 +71,7 @@ public function test_add_captcha() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_bbp_reply_nonce', 'hcaptcha_bbp_reply' );
$expected = new WP_Error();
@@ -87,7 +87,7 @@ public function test_verify() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$expected = new WP_Error( 'hcap_error', 'Please complete the hCaptcha.' );
$subject = new Reply();
diff --git a/.tests/php/integration/BuddyPress/CreateGroupTest.php b/.tests/php/integration/BuddyPress/CreateGroupTest.php
index 46451fe4..774d0d18 100644
--- a/.tests/php/integration/BuddyPress/CreateGroupTest.php
+++ b/.tests/php/integration/BuddyPress/CreateGroupTest.php
@@ -33,7 +33,7 @@ class CreateGroupTest extends HCaptchaPluginWPTestCase {
/**
* Tear down the test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
global $bp;
unset( $bp->signup );
@@ -44,7 +44,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test add_captcha().
*/
- public function test_hcap_bp_group_form() {
+ public function test_hcap_bp_group_form(): void {
$args = [
'action' => 'hcaptcha_bp_create_group',
'name' => 'hcaptcha_bp_create_group_nonce',
@@ -70,7 +70,7 @@ public function test_hcap_bp_group_form() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
FunctionMocker::replace(
'bp_is_group_creation_step',
static function ( $step_slug ) {
@@ -88,7 +88,7 @@ static function ( $step_slug ) {
/**
* Test verify() when not in step.
*/
- public function test_verify_not_in_step() {
+ public function test_verify_not_in_step(): void {
FunctionMocker::replace( 'bp_is_group_creation_step', false );
$subject = new CreateGroup();
@@ -102,7 +102,7 @@ public function test_verify_not_in_step() {
* @noinspection PhpUnusedParameterInspection
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
FunctionMocker::replace(
'bp_is_group_creation_step',
static function ( $step_slug ) {
@@ -142,8 +142,9 @@ static function ( $location, $status ) {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/BuddyPress/RegisterTest.php b/.tests/php/integration/BuddyPress/RegisterTest.php
index 9744e094..873618aa 100644
--- a/.tests/php/integration/BuddyPress/RegisterTest.php
+++ b/.tests/php/integration/BuddyPress/RegisterTest.php
@@ -32,7 +32,7 @@ class RegisterTest extends HCaptchaPluginWPTestCase {
/**
* Tear down the test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
global $bp;
unset( $bp->signup );
@@ -43,7 +43,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'action' => 'hcaptcha_bp_register',
'name' => 'hcaptcha_bp_register_nonce',
@@ -66,7 +66,7 @@ public function test_add_captcha() {
/**
* Test add_captcha() with error.
*/
- public function test_register_error() {
+ public function test_register_error(): void {
global $bp;
$args = [
@@ -102,7 +102,7 @@ public function test_register_error() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_bp_register_nonce', 'hcaptcha_bp_register' );
$subject = new Register();
@@ -113,7 +113,7 @@ public function test_verify() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
global $bp;
$bp->signup = (object) [
diff --git a/.tests/php/integration/CF7/AdminTest.php b/.tests/php/integration/CF7/AdminTest.php
index 2ba5cbe2..7c435dac 100644
--- a/.tests/php/integration/CF7/AdminTest.php
+++ b/.tests/php/integration/CF7/AdminTest.php
@@ -37,7 +37,7 @@ class AdminTest extends HCaptchaPluginWPTestCase {
/**
* Tear down the test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $GLOBALS['current_screen'], $_GET['post'], $_GET['page'] );
parent::tearDown();
@@ -53,7 +53,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @dataProvider dp_test_init_hooks
*/
- public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_admin, bool $expected ) {
+ public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_admin, bool $expected ): void {
$cf7_status = array_filter( [ $mode_auto ? 'form' : '', $mode_embed ? 'embed' : '' ] );
if ( $is_admin ) {
@@ -139,7 +139,7 @@ public function dp_test_init_hooks(): array {
*
* @return void
*/
- public function test_toplevel_page_wpcf7() {
+ public function test_toplevel_page_wpcf7(): void {
$form = <<
Edit Contact Form
@@ -227,8 +227,9 @@ public function test_toplevel_page_wpcf7() {
* Test add_tag_generator_hcaptcha().
*
* @return void
+ * @noinspection PhpUndefinedConstantInspection
*/
- public function test_add_tag_generator_hcaptcha() {
+ public function test_add_tag_generator_hcaptcha(): void {
require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php';
$tag_generator = WPCF7_TagGenerator::get_instance();
@@ -280,7 +281,7 @@ public function test_add_tag_generator_hcaptcha() {
*
* @return void
*/
- public function test_tag_generator_hcaptcha() {
+ public function test_tag_generator_hcaptcha(): void {
$args = [
'id' => 'cf7-hcaptcha',
'title' => 'hCaptcha',
@@ -348,8 +349,9 @@ public function test_tag_generator_hcaptcha() {
* Test enqueue_admin_scripts_before_cf7() and enqueue_admin_scripts_after_cf7().
*
* @noinspection PhpConditionAlreadyCheckedInspection
+ * @noinspection PhpUndefinedConstantInspection
*/
- public function test_enqueue_admin_scripts() {
+ public function test_enqueue_admin_scripts(): void {
global $wp_scripts;
set_current_screen( 'some' );
diff --git a/.tests/php/integration/CF7/CF7Test.php b/.tests/php/integration/CF7/CF7Test.php
index 6290eb16..d380f1ad 100644
--- a/.tests/php/integration/CF7/CF7Test.php
+++ b/.tests/php/integration/CF7/CF7Test.php
@@ -39,7 +39,7 @@ class CF7Test extends HCaptchaPluginWPTestCase {
/**
* Tear down the test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_REQUEST['_wpnonce'], $_POST['_wpcf7'], $_SERVER['REQUEST_URI'] );
hcaptcha()->form_shown = false;
diff --git a/.tests/php/integration/DelayedScript/DelayedScriptTest.php b/.tests/php/integration/DelayedScript/DelayedScriptTest.php
index 081a1352..414faa4a 100644
--- a/.tests/php/integration/DelayedScript/DelayedScriptTest.php
+++ b/.tests/php/integration/DelayedScript/DelayedScriptTest.php
@@ -25,7 +25,7 @@ class DelayedScriptTest extends HCaptchaWPTestCase {
* @noinspection JSUnresolvedReference
* @noinspection JSUnusedLocalSymbols
*/
- public function test_create() {
+ public function test_create(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
@@ -108,7 +108,7 @@ function delayedLoad() {
*
* @noinspection BadExpressionStatementJS
*/
- public function test_launch() {
+ public function test_launch(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/Divi/CommentTest.php b/.tests/php/integration/Divi/CommentTest.php
index 9aa398b3..757a3efd 100644
--- a/.tests/php/integration/Divi/CommentTest.php
+++ b/.tests/php/integration/Divi/CommentTest.php
@@ -21,7 +21,7 @@ class CommentTest extends HCaptchaWPTestCase {
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Comment();
self::assertSame( 10, has_filter( Comment::TAG . '_shortcode_output', [ $subject, 'add_captcha' ] ) );
@@ -30,7 +30,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$form_id = '3075';
$output = <<
@@ -61,7 +61,7 @@ public function test_add_captcha() {
/**
* Test add_captcha() when output is not a string.
*/
- public function test_add_captcha_when_output_is_not_a_string() {
+ public function test_add_captcha_when_output_is_not_a_string(): void {
$output = [ 'some string' ];
$module_slug = 'et_pb_comments';
@@ -73,7 +73,7 @@ public function test_add_captcha_when_output_is_not_a_string() {
/**
* Test add_captcha() when output has hCaptcha.
*/
- public function test_add_captcha_when_output_has_hcaptcha() {
+ public function test_add_captcha_when_output_has_hcaptcha(): void {
$output = 'some output with h-captcha attr';
$module_slug = 'et_pb_comments';
@@ -85,7 +85,7 @@ public function test_add_captcha_when_output_has_hcaptcha() {
/**
* Test add_captcha() in frontend builder.
*/
- public function test_add_captcha_in_frontend_builder() {
+ public function test_add_captcha_in_frontend_builder(): void {
$output = 'some string';
$module_slug = 'et_pb_comments';
diff --git a/.tests/php/integration/Divi/ContactTest.php b/.tests/php/integration/Divi/ContactTest.php
index 1c043075..a087d0bc 100644
--- a/.tests/php/integration/Divi/ContactTest.php
+++ b/.tests/php/integration/Divi/ContactTest.php
@@ -42,11 +42,8 @@ class ContactTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:disable WordPress.Security.NonceVerification.Missing
unset(
$_POST[ $this->cf_nonce_field ],
@@ -60,7 +57,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Contact();
self::assertSame(
@@ -87,7 +84,7 @@ public function test_constructor_and_init_hooks() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
FunctionMocker::replace( 'et_core_is_fb_enabled', false );
$output = '
@@ -196,7 +193,7 @@ public function test_add_captcha() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_add_captcha_in_frontend_builder() {
+ public function test_add_captcha_in_frontend_builder(): void {
FunctionMocker::replace( 'et_core_is_fb_enabled', true );
$output = [ 'some array' ];
@@ -214,7 +211,7 @@ public function test_add_captcha_in_frontend_builder() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_verify() {
+ public function test_verify(): void {
$return = 'some html';
$tag = 'et_pb_contact_form';
@@ -277,7 +274,7 @@ function ( $type, $var_name, $filter ) use ( $nonce, $current_form_fields ) {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$return = 'some html';
$tag = 'et_pb_contact_form';
@@ -338,7 +335,7 @@ function ( $type, $var_name, $filter ) use ( $nonce, $current_form_fields ) {
/**
* Test verify() with wrong tag.
*/
- public function test_verify_wrong_tag() {
+ public function test_verify_wrong_tag(): void {
$return = 'some html';
$tag = 'wrong tag';
@@ -357,7 +354,7 @@ public function test_verify_wrong_tag() {
* @throws ReflectionException ReflectionException.
* @noinspection PhpMissingParamTypeInspection
*/
- public function test_shortcode_attributes( $captcha, string $own_captcha ) {
+ public function test_shortcode_attributes( $captcha, string $own_captcha ): void {
$props = [ 'foo' => 'bar' ];
$attrs = [];
$slug = 'et_pb_contact_form';
@@ -401,7 +398,7 @@ public function dp_test_shortcode_attributes(): array {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_shortcode_attributes_with_wrong_slug() {
+ public function test_shortcode_attributes_with_wrong_slug(): void {
$props = [
'foo' => 'bar',
'captcha' => 'some',
@@ -423,7 +420,7 @@ public function test_shortcode_attributes_with_wrong_slug() {
/**
* Test enqueue_scripts().
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
$subject = new Contact();
self::assertFalse( wp_script_is( 'hcaptcha-divi' ) );
diff --git a/.tests/php/integration/Divi/EmailOptinTest.php b/.tests/php/integration/Divi/EmailOptinTest.php
index 49b40247..21019910 100644
--- a/.tests/php/integration/Divi/EmailOptinTest.php
+++ b/.tests/php/integration/Divi/EmailOptinTest.php
@@ -26,7 +26,7 @@ class EmailOptinTest extends HCaptchaWPTestCase {
/**
* Tear down test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
wp_dequeue_script( EmailOptin::HANDLE );
parent::tearDown();
@@ -35,7 +35,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new EmailOptin();
self::assertSame( 10, has_filter( 'et_pb_signup_form_field_html_submit_button', [ $subject, 'add_captcha' ] ) );
@@ -47,7 +47,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$wrap = '';
$html = <<
@@ -79,7 +79,7 @@ public function test_add_captcha() {
*
* @return void
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_get_verify_message_html( EmailOptin::NONCE, EmailOptin::ACTION );
$subject = new EmailOptin();
@@ -92,7 +92,7 @@ public function test_verify() {
*
* @return void
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$error_message = 'hCaptcha error: The hCaptcha is invalid.';
$et_core_die = FunctionMocker::replace( 'et_core_die' );
@@ -111,7 +111,7 @@ public function test_verify_not_verified() {
*
* @return void
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
hcaptcha()->form_shown = true;
self::assertFalse( wp_script_is( EmailOptin::HANDLE ) );
@@ -128,7 +128,7 @@ public function test_enqueue_scripts() {
*
* @return void
*/
- public function test_enqueue_scripts_when_form_was_not_shown() {
+ public function test_enqueue_scripts_when_form_was_not_shown(): void {
self::assertFalse( wp_script_is( EmailOptin::HANDLE ) );
$subject = new EmailOptin();
diff --git a/.tests/php/integration/Divi/LoginTest.php b/.tests/php/integration/Divi/LoginTest.php
index 73e80b99..5886ad16 100644
--- a/.tests/php/integration/Divi/LoginTest.php
+++ b/.tests/php/integration/Divi/LoginTest.php
@@ -21,7 +21,7 @@ class LoginTest extends HCaptchaWPTestCase {
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Login();
self::assertSame( 10, has_filter( Login::TAG . '_shortcode_output', [ $subject, 'add_divi_captcha' ] ) );
@@ -30,7 +30,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_divi_captcha().
*/
- public function test_add_divi_captcha() {
+ public function test_add_divi_captcha(): void {
FunctionMocker::replace( 'et_core_is_fb_enabled', false );
$output = '
@@ -118,7 +118,7 @@ class="hcaptcha-signature"
/**
* Test add_divi_captcha() in frontend builder.
*/
- public function test_add_divi_captcha_in_frontend_builder() {
+ public function test_add_divi_captcha_in_frontend_builder(): void {
FunctionMocker::replace( 'et_core_is_fb_enabled', true );
$output = 'some string';
@@ -132,7 +132,7 @@ public function test_add_divi_captcha_in_frontend_builder() {
/**
* Test add_divi_captcha() when the login limit is not exceeded.
*/
- public function test_add_divi_captcha_when_login_limit_is_not_exceeded() {
+ public function test_add_divi_captcha_when_login_limit_is_not_exceeded(): void {
$output = 'some string';
$module_slug = 'et_pb_login';
diff --git a/.tests/php/integration/ElementorPro/HCaptchaHandlerTest.php b/.tests/php/integration/ElementorPro/HCaptchaHandlerTest.php
index 057b3e73..95ab16f8 100644
--- a/.tests/php/integration/ElementorPro/HCaptchaHandlerTest.php
+++ b/.tests/php/integration/ElementorPro/HCaptchaHandlerTest.php
@@ -36,11 +36,8 @@ class HCaptchaHandlerTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
wp_dequeue_script( 'hcaptcha' );
wp_deregister_script( 'hcaptcha' );
@@ -61,7 +58,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @throws ReflectionException ReflectionException.
*/
- public function test_constructor() {
+ public function test_constructor(): void {
$subject = new HCaptchaHandler();
self::assertInstanceOf( Main::class, $this->get_protected_property( $subject, 'main' ) );
@@ -80,7 +77,7 @@ public function test_constructor() {
/**
* Test after_enqueue_scripts().
*/
- public function test_after_enqueue_scripts() {
+ public function test_after_enqueue_scripts(): void {
self::assertFalse( wp_script_is( 'admin-elementor-pro' ) );
$subject = new HCaptchaHandler();
@@ -102,7 +99,7 @@ public function test_after_enqueue_scripts() {
*
* @dataProvider dp_test_init
*/
- public function test_init( bool $enabled ) {
+ public function test_init( bool $enabled ): void {
if ( $enabled ) {
update_option(
'hcaptcha_settings',
@@ -209,7 +206,7 @@ public function dp_test_init(): array {
/**
* Test register_action().
*/
- public function test_register_action() {
+ public function test_register_action(): void {
$subject = new HCaptchaHandler();
$module = Mockery::mock( Module::class );
@@ -221,7 +218,7 @@ public function test_register_action() {
/**
* Test get_site_key().
*/
- public function test_get_site_key() {
+ public function test_get_site_key(): void {
$site_key = 'some site key';
update_option( 'hcaptcha_settings', [ 'site_key' => $site_key ] );
@@ -233,7 +230,7 @@ public function test_get_site_key() {
/**
* Test get_secret_key().
*/
- public function test_get_secret_key() {
+ public function test_get_secret_key(): void {
$secret_key = 'some secret key';
update_option( 'hcaptcha_settings', [ 'secret_key' => $secret_key ] );
@@ -245,7 +242,7 @@ public function test_get_secret_key() {
/**
* Test get_hcaptcha_theme().
*/
- public function test_get_hcaptcha_theme() {
+ public function test_get_hcaptcha_theme(): void {
$theme = 'some theme';
update_option( 'hcaptcha_settings', [ 'theme' => $theme ] );
@@ -257,7 +254,7 @@ public function test_get_hcaptcha_theme() {
/**
* Test get_hcaptcha_size().
*/
- public function test_get_hcaptcha_size() {
+ public function test_get_hcaptcha_size(): void {
$size = 'some size';
update_option( 'hcaptcha_settings', [ 'size' => $size ] );
@@ -269,7 +266,7 @@ public function test_get_hcaptcha_size() {
/**
* Test get_setup_message().
*/
- public function test_get_setup_message() {
+ public function test_get_setup_message(): void {
self::assertSame(
'To use hCaptcha, you need to add the Site and Secret keys.',
HCaptchaHandler::get_setup_message()
@@ -286,7 +283,7 @@ public function test_get_setup_message() {
* @dataProvider dp_test_is_enabled
* @noinspection PhpMissingParamTypeInspection
*/
- public function test_is_enabled( $site_key, $secret_key, bool $expected ) {
+ public function test_is_enabled( $site_key, $secret_key, bool $expected ): void {
$settings = [];
if ( $site_key ) {
@@ -323,7 +320,7 @@ public function dp_test_is_enabled(): array {
/**
* Test localize_settings().
*/
- public function test_localize_settings() {
+ public function test_localize_settings(): void {
$settings = [
'forms' => [
'hcaptcha' => [
@@ -380,7 +377,7 @@ public function test_localize_settings() {
/**
* Test enqueue_scripts().
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
self::assertFalse( wp_script_is( 'elementor-hcaptcha-api' ) );
self::assertFalse( wp_script_is( 'hcaptcha' ) );
self::assertFalse( wp_script_is( 'hcaptcha-elementor-pro' ) );
@@ -403,7 +400,7 @@ public function test_enqueue_scripts() {
/**
* Test validation.
*/
- public function test_validation() {
+ public function test_validation(): void {
$fields = [
'field_014ea7c' =>
[
@@ -433,7 +430,7 @@ public function test_validation() {
/**
* Test validation.
*/
- public function test_validation_with_empty_fields() {
+ public function test_validation_with_empty_fields(): void {
$fields = [];
$record = Mockery::mock( Form_Record::class );
@@ -449,7 +446,7 @@ public function test_validation_with_empty_fields() {
/**
* Test validation with no hCaptcha response.
*/
- public function test_validation_with_no_captcha() {
+ public function test_validation_with_no_captcha(): void {
$fields = [
'field_014ea7c' =>
[
@@ -477,7 +474,7 @@ public function test_validation_with_no_captcha() {
/**
* Test validation with failed hCaptcha.
*/
- public function test_validation_with_failed_captcha() {
+ public function test_validation_with_failed_captcha(): void {
$fields = [
'field_014ea7c' =>
[
@@ -508,7 +505,7 @@ public function test_validation_with_failed_captcha() {
/**
* Test validation with empty hCaptcha.
*/
- public function test_validation_with_empty_captcha() {
+ public function test_validation_with_empty_captcha(): void {
$fields = [
'field_014ea7c' =>
[
@@ -539,7 +536,7 @@ public function test_validation_with_empty_captcha() {
/**
* Test render_field.
*/
- public function test_render_field() {
+ public function test_render_field(): void {
$site_key = 'some site key';
$theme = 'some theme';
$size = 'some size';
@@ -599,7 +596,7 @@ public function test_render_field() {
/**
* Test add_field_type().
*/
- public function test_add_field_type() {
+ public function test_add_field_type(): void {
$field_types = [
'text' => 'text',
'recaptcha' => 'reCaptcha',
@@ -616,7 +613,7 @@ public function test_add_field_type() {
/**
* Test modify_controls().
*/
- public function test_modify_controls() {
+ public function test_modify_controls(): void {
$args = [];
$control_id = 'form_fields';
@@ -856,7 +853,7 @@ public function test_modify_controls() {
/**
* Test filter_field_item().
*/
- public function test_filter_field_item() {
+ public function test_filter_field_item(): void {
$text_item = [
'field_type' => 'text',
'field_label' => true,
@@ -877,7 +874,7 @@ public function test_filter_field_item() {
*
* @return void
*/
- public function test_print_footer_scripts() {
+ public function test_print_footer_scripts(): void {
$subject = new HCaptchaHandler();
$subject->print_footer_scripts();
@@ -894,8 +891,9 @@ public function test_print_footer_scripts() {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/FluentForm/FormTest.php b/.tests/php/integration/FluentForm/FormTest.php
index 0229ee7b..4648b419 100644
--- a/.tests/php/integration/FluentForm/FormTest.php
+++ b/.tests/php/integration/FluentForm/FormTest.php
@@ -27,7 +27,7 @@ class FormTest extends HCaptchaWPTestCase {
/**
* Test constructor and init hooks.
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Form();
self::assertSame(
@@ -51,7 +51,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
hcaptcha()->init_hooks();
$form_id = 1;
@@ -99,7 +99,7 @@ public function test_add_captcha() {
/**
* Test add_captcha() with own captcha.
*/
- public function test_add_captcha_with_own_captcha() {
+ public function test_add_captcha_with_own_captcha(): void {
hcaptcha()->init_hooks();
$form = (object) [];
@@ -120,7 +120,7 @@ public function test_add_captcha_with_own_captcha() {
*
* @return void
*/
- public function test_verify_no_success() {
+ public function test_verify_no_success(): void {
$errors = [
'some_error' => 'Some error description',
'h-captcha-response' => [ 'Please complete the hCaptcha.' ],
@@ -142,7 +142,7 @@ public function test_verify_no_success() {
*
* @return void
*/
- public function test_verify() {
+ public function test_verify(): void {
$errors = [
'some_error' => 'Some error description',
];
diff --git a/.tests/php/integration/GravityForms/FieldTest.php b/.tests/php/integration/GravityForms/FieldTest.php
index d5d52665..a1f7e046 100644
--- a/.tests/php/integration/GravityForms/FieldTest.php
+++ b/.tests/php/integration/GravityForms/FieldTest.php
@@ -14,7 +14,6 @@
use HCaptcha\GravityForms\Base;
use HCaptcha\GravityForms\Field;
-use HCaptcha\Helpers\HCaptcha;
use HCaptcha\Tests\Integration\HCaptchaWPTestCase;
use tad\FunctionMocker\FunctionMocker;
@@ -30,7 +29,7 @@ class FieldTest extends HCaptchaWPTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST['action'], $_POST['field'], $_GET['id'] );
parent::tearDown();
}
@@ -42,7 +41,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @dataProvider dp_test_constructor_init_and_init_hooks
*/
- public function test_constructor_init_and_init_hooks( bool $mode_embed ) {
+ public function test_constructor_init_and_init_hooks( bool $mode_embed ): void {
if ( $mode_embed ) {
update_option( 'hcaptcha_settings', [ 'gravity_status' => [ 'embed' ] ] );
} else {
@@ -94,7 +93,7 @@ public function dp_test_constructor_init_and_init_hooks(): array {
*
* @return void
*/
- public function test_add_to_field_groups() {
+ public function test_add_to_field_groups(): void {
$expected = [
'advanced_fields' => [
'fields' => [
@@ -116,7 +115,7 @@ public function test_add_to_field_groups() {
*
* @return void
*/
- public function test_get_form_editor_field_title() {
+ public function test_get_form_editor_field_title(): void {
$subject = new Field();
self::assertSame( 'hCaptcha', $subject->get_form_editor_field_title() );
@@ -127,7 +126,7 @@ public function test_get_form_editor_field_title() {
*
* @return void
*/
- public function test_get_form_editor_field_description() {
+ public function test_get_form_editor_field_description(): void {
$expected =
'Adds a hCaptcha field to your form to help protect your website from spam and bot abuse.' .
' ' .
@@ -143,7 +142,7 @@ public function test_get_form_editor_field_description() {
*
* @return void
*/
- public function test_get_form_editor_field_icon() {
+ public function test_get_form_editor_field_icon(): void {
$expected = HCAPTCHA_URL . '/assets/images/hcaptcha-icon-black-and-white.svg';
$subject = new Field();
@@ -156,7 +155,7 @@ public function test_get_form_editor_field_icon() {
*
* @return void
*/
- public function test_get_form_editor_field_settings() {
+ public function test_get_form_editor_field_settings(): void {
$expected = [
'label_placement_setting',
'description_setting',
@@ -173,7 +172,7 @@ public function test_get_form_editor_field_settings() {
*
* @return void
*/
- public function test_get_field_input() {
+ public function test_get_field_input(): void {
$form_id = 23;
$field_id = 'input_0';
$tabindex = 0;
@@ -207,7 +206,7 @@ public function test_get_field_input() {
*
* @return void
*/
- public function test_disable_duplication() {
+ public function test_disable_duplication(): void {
$duplicate_field_link = '#some-link';
$field_id = 55;
$field = (object) [];
@@ -263,7 +262,7 @@ static function ( $name ) {
*
* @return void
*/
- public function test_enqueue_admin_script() {
+ public function test_enqueue_admin_script(): void {
$params = [
'onlyOne' => 'Only one hCaptcha field can be added to the form.',
'OKBtnText' => 'OK',
@@ -306,7 +305,7 @@ public function test_enqueue_admin_script() {
*
* @return void
*/
- public function test_print_hcaptcha_scripts() {
+ public function test_print_hcaptcha_scripts(): void {
$subject = new Field();
self::assertFalse( $subject->print_hcaptcha_scripts( false ) );
diff --git a/.tests/php/integration/GravityForms/FormTest.php b/.tests/php/integration/GravityForms/FormTest.php
index f46e606b..16d3efea 100644
--- a/.tests/php/integration/GravityForms/FormTest.php
+++ b/.tests/php/integration/GravityForms/FormTest.php
@@ -29,7 +29,7 @@ class FormTest extends HCaptchaWPTestCase {
/**
* Tear down test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
unset( $GLOBALS['current_screen'] );
@@ -43,7 +43,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @dataProvider dp_test_constructor_and_init_hooks
*/
- public function test_constructor_and_init_hooks( bool $mode_auto ) {
+ public function test_constructor_and_init_hooks( bool $mode_auto ): void {
if ( $mode_auto ) {
update_option( 'hcaptcha_settings', [ 'gravity_status' => [ 'form' ] ] );
} else {
@@ -89,7 +89,7 @@ public function dp_test_constructor_and_init_hooks(): array {
*
* @dataProvider dp_test_add_captcha
*/
- public function test_add_captcha( bool $is_admin ) {
+ public function test_add_captcha( bool $is_admin ): void {
$form_id = 23;
$form = [
'id' => $form_id,
@@ -131,7 +131,7 @@ public function dp_test_add_captcha(): array {
/**
* Test add_captcha() in embed mode.
*/
- public function test_add_captcha_in_embed_mode() {
+ public function test_add_captcha_in_embed_mode(): void {
$button_input = '';
$hcaptcha_field = (object) [
'type' => 'hcaptcha',
@@ -183,7 +183,7 @@ public function test_add_captcha_in_embed_mode() {
* @return void
* @dataProvider dp_test_verify
*/
- public function test_verify( string $mode ) {
+ public function test_verify( string $mode ): void {
$form_id = 23;
$hcaptcha_field = (object) [
'type' => 'hcaptcha',
@@ -222,7 +222,7 @@ public function test_verify( string $mode ) {
* @return void
* @dataProvider dp_test_verify
*/
- public function test_verify_not_verified( string $mode ) {
+ public function test_verify_not_verified( string $mode ): void {
$form_id = 23;
$hcaptcha_field = (object) [
'type' => 'hcaptcha',
@@ -249,7 +249,7 @@ public function test_verify_not_verified( string $mode ) {
FunctionMocker::replace( 'GFFormsModel::get_form_meta', $form );
- $this->prepare_hcaptcha_verify_post( Form::NONCE, Form::ACTION, false );
+ $this->prepare_hcaptcha_verify_post( Base::NONCE, Base::ACTION, false );
update_option( 'hcaptcha_settings', [ 'gravity_status' => [ $mode ] ] );
hcaptcha()->init_hooks();
@@ -276,7 +276,7 @@ public function dp_test_verify(): array {
*
* @return void
*/
- public function test_verify_when_should_not_be_verified() {
+ public function test_verify_when_should_not_be_verified(): void {
$form_id = 2;
$nested_form_id = 9;
$multipage_form_id = 3;
@@ -379,7 +379,7 @@ static function ( $id ) use (
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_form_validation_errors() {
+ public function test_form_validation_errors(): void {
$errors = [];
$form = [];
$error_message = 'Some hCaptcha error.';
@@ -406,7 +406,7 @@ public function test_form_validation_errors() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_form_validation_errors_markup() {
+ public function test_form_validation_errors_markup(): void {
$error_message = 'Some hCaptcha error.';
$validation_errors_markup = '
Some text with hCaptcha: ';
$expected = "
$error_message
";
@@ -425,8 +425,9 @@ public function test_form_validation_errors_markup() {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
@@ -491,7 +492,7 @@ static function ( $name ) {
*
* @return void
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
self::assertFalse( wp_script_is( Form::HANDLE ) );
$subject = new Form();
diff --git a/.tests/php/integration/HCaptchaPluginWPTestCase.php b/.tests/php/integration/HCaptchaPluginWPTestCase.php
index f34fe4e1..c7ab16a1 100644
--- a/.tests/php/integration/HCaptchaPluginWPTestCase.php
+++ b/.tests/php/integration/HCaptchaPluginWPTestCase.php
@@ -41,7 +41,7 @@ class HCaptchaPluginWPTestCase extends HCaptchaWPTestCase {
/**
* Teardown after class.
*/
- public static function tearDownAfterClass(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public static function tearDownAfterClass(): void {
deactivate_plugins( static::$plugin );
parent::tearDownAfterClass();
@@ -50,7 +50,7 @@ public static function tearDownAfterClass(): void { // phpcs:ignore PHPCompatib
/**
* Setup test.
*/
- public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function setUp(): void {
$plugins_requiring_php = [
'7.2' => [ 'ninja-forms/ninja-forms.php' ],
'7.4' => [ 'contact-form-7/wp-contact-form-7.php', 'woocommerce/woocommerce.php' ],
diff --git a/.tests/php/integration/HCaptchaWPTestCase.php b/.tests/php/integration/HCaptchaWPTestCase.php
index a1258f1c..fc7114ec 100644
--- a/.tests/php/integration/HCaptchaWPTestCase.php
+++ b/.tests/php/integration/HCaptchaWPTestCase.php
@@ -13,7 +13,6 @@
namespace HCaptcha\Tests\Integration;
use Codeception\TestCase\WPTestCase;
-use HCaptcha\Helpers\HCaptcha;
use Mockery;
use ReflectionClass;
use ReflectionException;
@@ -28,7 +27,7 @@ class HCaptchaWPTestCase extends WPTestCase {
/**
* Setup test
*/
- public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function setUp(): void {
FunctionMocker::setUp();
parent::setUp();
@@ -41,7 +40,7 @@ public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclara
/**
* End test
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
unset( $_POST, $_SERVER['REQUEST_URI'], $_SERVER['HTTP_CLIENT_IP'] );
@@ -63,7 +62,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @throws ReflectionException Reflection exception.
*/
- protected function get_protected_property( $subject, string $property_name ) {
+ protected function get_protected_property( object $subject, string $property_name ) {
$property = ( new ReflectionClass( $subject ) )->getProperty( $property_name );
$property->setAccessible( true );
@@ -84,7 +83,7 @@ protected function get_protected_property( $subject, string $property_name ) {
*
* @throws ReflectionException Reflection exception.
*/
- protected function set_protected_property( $subject, string $property_name, $value ) {
+ protected function set_protected_property( object $subject, string $property_name, $value ): void {
$property = ( new ReflectionClass( $subject ) )->getProperty( $property_name );
$property->setAccessible( true );
@@ -103,7 +102,7 @@ protected function set_protected_property( $subject, string $property_name, $val
*
* @throws ReflectionException Reflection exception.
*/
- protected function set_method_accessibility( $subject, string $method_name, bool $accessible = true ): ReflectionMethod {
+ protected function set_method_accessibility( object $subject, string $method_name, bool $accessible = true ): ReflectionMethod {
$method = ( new ReflectionClass( $subject ) )->getMethod( $method_name );
$method->setAccessible( $accessible );
@@ -186,7 +185,7 @@ class="h-captcha"
*
* @noinspection PhpMissingParamTypeInspection
*/
- protected function prepare_hcaptcha_request_verify( string $hcaptcha_response, $result = true ) {
+ protected function prepare_hcaptcha_request_verify( string $hcaptcha_response, $result = true ): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( ! isset( $_POST['h-captcha-response'] ) ) {
$_POST[ HCAPTCHA_NONCE ] = wp_create_nonce( HCAPTCHA_ACTION );
@@ -245,7 +244,7 @@ static function ( $preempt, $parsed_args, $url ) use ( $hcaptcha_secret_key, $hc
* @param bool|null $result Desired result.
*
* @noinspection PhpMissingParamTypeInspection*/
- protected function prepare_hcaptcha_verify_post( string $nonce_field_name, string $nonce_action_name, $result = true ) {
+ protected function prepare_hcaptcha_verify_post( string $nonce_field_name, string $nonce_action_name, $result = true ): void {
if ( null === $result ) {
return;
}
@@ -267,7 +266,7 @@ protected function prepare_hcaptcha_verify_post( string $nonce_field_name, strin
*
* @noinspection PhpMissingParamTypeInspection
*/
- protected function prepare_hcaptcha_get_verify_message( string $nonce_field_name, string $nonce_action_name, $result = true ) {
+ protected function prepare_hcaptcha_get_verify_message( string $nonce_field_name, string $nonce_action_name, $result = true ): void {
$this->prepare_hcaptcha_verify_post( $nonce_field_name, $nonce_action_name, $result );
}
@@ -280,7 +279,7 @@ protected function prepare_hcaptcha_get_verify_message( string $nonce_field_name
*
* @noinspection PhpMissingParamTypeInspection
*/
- protected function prepare_hcaptcha_get_verify_message_html( string $nonce_field_name, string $nonce_action_name, $result = true ) {
+ protected function prepare_hcaptcha_get_verify_message_html( string $nonce_field_name, string $nonce_action_name, $result = true ): void {
$this->prepare_hcaptcha_get_verify_message( $nonce_field_name, $nonce_action_name, $result );
}
diff --git a/.tests/php/integration/Helpers/HCaptchaTest.php b/.tests/php/integration/Helpers/HCaptchaTest.php
index 35416062..a00857b2 100644
--- a/.tests/php/integration/Helpers/HCaptchaTest.php
+++ b/.tests/php/integration/Helpers/HCaptchaTest.php
@@ -27,7 +27,7 @@ class HCaptchaTest extends HCaptchaWPTestCase {
/**
* Tear down test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST[ HCaptcha::HCAPTCHA_WIDGET_ID ] );
hcaptcha()->form_shown = false;
@@ -40,7 +40,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @noinspection PhpConditionAlreadyCheckedInspection
*/
- public function test_form() {
+ public function test_form(): void {
hcaptcha()->init_hooks();
self::assertSame( $this->get_hcap_form(), HCaptcha::form() );
@@ -71,7 +71,7 @@ public function test_form() {
*
* @noinspection PhpConditionAlreadyCheckedInspection
*/
- public function test_form_display() {
+ public function test_form_display(): void {
self::assertFalse( hcaptcha()->form_shown );
ob_start();
@@ -125,7 +125,7 @@ public function test_form_display() {
*
* @return void
*/
- public function test_check_signature() {
+ public function test_check_signature(): void {
$const = HCaptcha::HCAPTCHA_SIGNATURE;
$class_name = 'SomeClass';
$form_id = 'some_id';
@@ -157,7 +157,7 @@ public function test_check_signature() {
*
* @return void
*/
- public function test_get_widget_id() {
+ public function test_get_widget_id(): void {
$default_id = [
'source' => [],
'form_id' => 0,
@@ -186,7 +186,7 @@ public function test_get_widget_id() {
*
* @return void
*/
- public function test_get_hcaptcha_plugin_notice() {
+ public function test_get_hcaptcha_plugin_notice(): void {
$expected = [
'label' => 'hCaptcha plugin is active',
'description' => 'When hCaptcha plugin is active and integration is on, hCaptcha settings must be modified on the
General settings page.',
@@ -200,7 +200,7 @@ public function test_get_hcaptcha_plugin_notice() {
*
* @return void
*/
- public function test_js_display() {
+ public function test_js_display(): void {
$js = <<
prepare_hcaptcha_get_verify_message( 'hcaptcha_jetpack_nonce', 'hcaptcha_jetpack' );
$subject = new JetpackForm();
@@ -64,7 +64,7 @@ public function test_jetpack_verify() {
/**
* Test jetpack_verify() not verified.
*/
- public function test_jetpack_verify_not_verified() {
+ public function test_jetpack_verify_not_verified(): void {
$error = new WP_Error( 'invalid_hcaptcha', 'The hCaptcha is invalid.' );
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_jetpack_nonce', 'hcaptcha_jetpack', false );
@@ -81,7 +81,7 @@ public function test_jetpack_verify_not_verified() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_error_message() {
+ public function test_error_message(): void {
$hcaptcha_content = 'some content';
$error_message = 'some error message';
diff --git a/.tests/php/integration/Jetpack/JetpackFormTest.php b/.tests/php/integration/Jetpack/JetpackFormTest.php
index 71d65411..a57d8135 100644
--- a/.tests/php/integration/Jetpack/JetpackFormTest.php
+++ b/.tests/php/integration/Jetpack/JetpackFormTest.php
@@ -25,7 +25,7 @@ class JetpackFormTest extends HCaptchaWPTestCase {
*
* @dataProvider dp_test_add_captcha
*/
- public function test_add_captcha( string $content, string $expected ) {
+ public function test_add_captcha( string $content, string $expected ): void {
$subject = new JetpackForm();
self::assertSame( $expected, $subject->add_captcha( $content ) );
diff --git a/.tests/php/integration/Mailchimp/FormTest.php b/.tests/php/integration/Mailchimp/FormTest.php
index 5c8e1ba9..9c4f423e 100644
--- a/.tests/php/integration/Mailchimp/FormTest.php
+++ b/.tests/php/integration/Mailchimp/FormTest.php
@@ -24,7 +24,7 @@ class FormTest extends HCaptchaWPTestCase {
/**
* Test add_hcap_error_messages().
*/
- public function test_add_hcap_error_messages() {
+ public function test_add_hcap_error_messages(): void {
$form = Mockery::mock( MC4WP_Form::class );
$messages = [
@@ -94,7 +94,7 @@ public function test_add_hcap_error_messages() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$form_id = 5;
$content = '';
$args = [
@@ -120,7 +120,7 @@ public function test_add_captcha() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_verify_post( 'hcaptcha_mailchimp_nonce', 'hcaptcha_mailchimp' );
$mc4wp_form = Mockery::mock( MC4WP_Form::class );
@@ -133,7 +133,7 @@ public function test_verify() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$this->prepare_hcaptcha_verify_post( 'hcaptcha_mailchimp_nonce', 'hcaptcha_mailchimp', false );
$mc4wp_form = Mockery::mock( MC4WP_Form::class );
diff --git a/.tests/php/integration/MainPluginFileTest.php b/.tests/php/integration/MainPluginFileTest.php
index 3f0f9cff..16109bb0 100644
--- a/.tests/php/integration/MainPluginFileTest.php
+++ b/.tests/php/integration/MainPluginFileTest.php
@@ -24,7 +24,7 @@ class MainPluginFileTest extends HCaptchaWPTestCase {
*
* @noinspection HttpUrlsUsage
*/
- public function test_main_file_content() {
+ public function test_main_file_content(): void {
$expected = [
'version' => HCAPTCHA_VERSION,
];
@@ -67,7 +67,7 @@ public function test_main_file_content() {
/**
* Test that readme.txt contains proper stable tag.
*/
- public function test_stable_tag_in_readme_txt() {
+ public function test_stable_tag_in_readme_txt(): void {
$expected = [
'stable_tag' => HCAPTCHA_VERSION,
];
@@ -85,7 +85,7 @@ public function test_stable_tag_in_readme_txt() {
/**
* Test that readme.txt contains changelog records for the current version.
*/
- public function test_changelog() {
+ public function test_changelog(): void {
$readme_file = HCAPTCHA_PATH . '/readme.txt';
$changelog_file = HCAPTCHA_PATH . '/changelog.txt';
diff --git a/.tests/php/integration/MemberPress/RegisterTest.php b/.tests/php/integration/MemberPress/RegisterTest.php
index 5995ce4e..2b34ff61 100644
--- a/.tests/php/integration/MemberPress/RegisterTest.php
+++ b/.tests/php/integration/MemberPress/RegisterTest.php
@@ -20,7 +20,7 @@ class RegisterTest extends HCaptchaWPTestCase {
/**
* Test constructor and init hooks.
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Register();
self::assertSame(
@@ -36,7 +36,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$subject = new Register();
$expected = $this->get_hcap_form(
@@ -61,7 +61,7 @@ public function test_add_captcha() {
*
* @return void
*/
- public function test_verify() {
+ public function test_verify(): void {
$subject = new Register();
$errors = [ 'some errors' ];
@@ -79,7 +79,7 @@ public function test_verify() {
*
* @return void
*/
- public function test_verify_no_success() {
+ public function test_verify_no_success(): void {
$subject = new Register();
$errors = [ 'some errors' ];
diff --git a/.tests/php/integration/Migrations/MigrationsTest.php b/.tests/php/integration/Migrations/MigrationsTest.php
index 39a572f8..070d9271 100644
--- a/.tests/php/integration/Migrations/MigrationsTest.php
+++ b/.tests/php/integration/Migrations/MigrationsTest.php
@@ -23,12 +23,8 @@ class MigrationsTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @return void
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_GET['service-worker'], $GLOBALS['current_screen'] );
parent::tearDown();
@@ -43,7 +39,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
* @return void
* @dataProvider dp_test_init_and_init_hooks
*/
- public function test_init_and_init_hooks( bool $worker, bool $admin, $expected ) {
+ public function test_init_and_init_hooks( bool $worker, bool $admin, $expected ): void {
if ( $worker ) {
$_GET['service-worker'] = 'some';
}
@@ -76,7 +72,7 @@ public function dp_test_init_and_init_hooks(): array {
*
* @return void
*/
- public function test_migrate() {
+ public function test_migrate(): void {
FunctionMocker::replace( 'time', time() );
$time = time();
@@ -168,7 +164,7 @@ private function compare_migrated( array $expected_option, array $option ): bool
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_migrate_360_when_wpforms_status_not_set() {
+ public function test_migrate_360_when_wpforms_status_not_set(): void {
$method = 'migrate_360';
$subject = Mockery::mock( Migrations::class )->makePartial();
@@ -187,7 +183,7 @@ public function test_migrate_360_when_wpforms_status_not_set() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_migrate_4_0_0() {
+ public function test_migrate_4_0_0(): void {
global $wpdb;
$method = 'migrate_4_0_0';
diff --git a/.tests/php/integration/NF/FieldTest.php b/.tests/php/integration/NF/FieldTest.php
index ef5928c3..20decfc5 100644
--- a/.tests/php/integration/NF/FieldTest.php
+++ b/.tests/php/integration/NF/FieldTest.php
@@ -31,7 +31,7 @@ class FieldTest extends HCaptchaPluginWPTestCase {
*
* @noinspection PhpUndefinedMethodInspection
*/
- public function test_constructor() {
+ public function test_constructor(): void {
$subject = new Field();
self::assertSame( 'hCaptcha', $subject->get_nicename() );
@@ -40,7 +40,7 @@ public function test_constructor() {
/**
* Test validate().
*/
- public function test_validate() {
+ public function test_validate(): void {
$field = [ 'value' => 'some value' ];
$this->prepare_hcaptcha_request_verify( $field['value'] );
@@ -50,9 +50,9 @@ public function test_validate() {
}
/**
- * Test validate() without field.
+ * Test validate() without a field.
*/
- public function test_validate_without_field() {
+ public function test_validate_without_field(): void {
$subject = new Field();
self::assertSame( 'Please complete the hCaptcha.', $subject->validate( [], null ) );
@@ -61,7 +61,7 @@ public function test_validate_without_field() {
/**
* Test validate() when not validated.
*/
- public function test_validate_not_validated() {
+ public function test_validate_not_validated(): void {
$field = [ 'value' => 'some value' ];
$this->prepare_hcaptcha_request_verify( $field['value'], false );
diff --git a/.tests/php/integration/NF/NFTest.php b/.tests/php/integration/NF/NFTest.php
index ec7dc415..3f3a7eb3 100644
--- a/.tests/php/integration/NF/NFTest.php
+++ b/.tests/php/integration/NF/NFTest.php
@@ -31,7 +31,7 @@ class NFTest extends HCaptchaPluginWPTestCase {
/**
* Test init_hooks().
*/
- public function test_init_hooks() {
+ public function test_init_hooks(): void {
$subject = new NF();
self::assertSame(
@@ -52,7 +52,7 @@ public function test_init_hooks() {
/**
* Test register_fields.
*/
- public function test_register_fields() {
+ public function test_register_fields(): void {
$fields = [ 'some field' ];
$fields = ( new NF() )->register_fields( $fields );
@@ -63,7 +63,7 @@ public function test_register_fields() {
/**
* Test template_file_paths().
*/
- public function test_template_file_paths() {
+ public function test_template_file_paths(): void {
$paths = [ 'some path' ];
$expected = array_merge( $paths, [ str_replace( '\\', '/', HCAPTCHA_PATH . '/src/php/NF/templates/' ) ] );
@@ -81,7 +81,7 @@ static function ( &$item ) {
/**
* Test localize_field().
*/
- public function test_localize_field() {
+ public function test_localize_field(): void {
$form_id = 1;
$field_id = 5;
$field = [
@@ -143,7 +143,7 @@ class="h-captcha"
/**
* Test nf_captcha_script().
*/
- public function test_nf_captcha_script() {
+ public function test_nf_captcha_script(): void {
$subject = new NF();
$subject->nf_captcha_script();
diff --git a/.tests/php/integration/Stubs/GFFormsModel.php b/.tests/php/integration/Stubs/GFFormsModel.php
index 3450b0ac..16677a1b 100644
--- a/.tests/php/integration/Stubs/GFFormsModel.php
+++ b/.tests/php/integration/Stubs/GFFormsModel.php
@@ -20,6 +20,8 @@ class GFFormsModel {
*
* @return array|null
* @noinspection PhpUnusedParameterInspection
+ * @noinspection PhpMissingReturnTypeInspection
+ * @noinspection ReturnTypeCanBeDeclaredInspection
*/
public static function get_form_meta( int $form_id ) {
return [];
@@ -32,6 +34,9 @@ public static function get_form_meta( int $form_id ) {
* @param string|int $field_id The field or input ID.
*
* @return GF_Field|null
+ * @noinspection PhpMissingReturnTypeInspection
+ * @noinspection ReturnTypeCanBeDeclaredInspection
+ * @noinspection PhpUnusedParameterInspection
*/
public static function get_field( $form_or_id, $field_id ) {
return null;
diff --git a/.tests/php/integration/Stubs/GF_Fields.php b/.tests/php/integration/Stubs/GF_Fields.php
index e701b554..6af3b546 100644
--- a/.tests/php/integration/Stubs/GF_Fields.php
+++ b/.tests/php/integration/Stubs/GF_Fields.php
@@ -19,6 +19,7 @@ class GF_Fields {
* @param GF_Field $field Field.
*
* @return void
+ * @noinspection ReturnTypeCanBeDeclaredInspection
*/
public static function register( GF_Field $field ) {}
}
diff --git a/.tests/php/integration/Subscriber/FormTest.php b/.tests/php/integration/Subscriber/FormTest.php
index 55ec1dbe..6c325df3 100644
--- a/.tests/php/integration/Subscriber/FormTest.php
+++ b/.tests/php/integration/Subscriber/FormTest.php
@@ -20,7 +20,7 @@ class FormTest extends HCaptchaWPTestCase {
/**
* Tests add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
hcaptcha()->init_hooks();
$content = '';
@@ -41,7 +41,7 @@ public function test_add_captcha() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_subscriber_form_nonce', 'hcaptcha_subscriber_form' );
$subject = new Form();
@@ -53,7 +53,7 @@ public function test_verify() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_subscriber_form_nonce', 'hcaptcha_subscriber_form', false );
$subject = new Form();
diff --git a/.tests/php/integration/UM/LoginTest.php b/.tests/php/integration/UM/LoginTest.php
index 5f5a53c9..b07e0743 100644
--- a/.tests/php/integration/UM/LoginTest.php
+++ b/.tests/php/integration/UM/LoginTest.php
@@ -30,10 +30,8 @@ class LoginTest extends HCaptchaPluginWPTestCase {
*
* @return void
* @noinspection PhpUndefinedFunctionInspection
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
UM()->form()->errors = null;
parent::tearDown();
@@ -42,7 +40,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = $this->get_subject();
self::assertSame(
@@ -72,7 +70,7 @@ public function test_constructor_and_init_hooks() {
* @dataProvider dp_test_add_um_captcha
* @return void
*/
- public function test_add_um_captcha( array $fields, array $expected ) {
+ public function test_add_um_captcha( array $fields, array $expected ): void {
$subject = $this->get_subject();
self::assertSame( $expected, $subject->add_um_captcha( $fields ) );
@@ -220,7 +218,7 @@ public function dp_test_add_um_captcha(): array {
* @return void
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_display_captcha() {
+ public function test_display_captcha(): void {
$subject = $this->get_subject();
$mode = 'wrong mode';
@@ -264,7 +262,7 @@ public function test_display_captcha() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$subject = $this->get_subject();
$mode = $subject::UM_MODE;
$args = [];
@@ -292,7 +290,7 @@ public function test_verify() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$subject = $this->get_subject();
$mode = $subject::UM_MODE;
@@ -311,7 +309,7 @@ public function test_verify_not_verified() {
*
* @return void
*/
- public function test_mute_login_hcaptcha_notice() {
+ public function test_mute_login_hcaptcha_notice(): void {
$subject = $this->get_subject();
$message = 'some error message';
diff --git a/.tests/php/integration/UM/LostPasswordTest.php b/.tests/php/integration/UM/LostPasswordTest.php
index 04467051..54f96566 100644
--- a/.tests/php/integration/UM/LostPasswordTest.php
+++ b/.tests/php/integration/UM/LostPasswordTest.php
@@ -30,10 +30,8 @@ class LostPasswordTest extends HCaptchaPluginWPTestCase {
*
* @return void
* @noinspection PhpUndefinedFunctionInspection
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
UM()->form()->errors = null;
parent::tearDown();
@@ -42,7 +40,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = $this->get_subject();
self::assertSame(
@@ -68,7 +66,7 @@ public function test_constructor_and_init_hooks() {
*
* @return void
*/
- public function test_um_after_password_reset_fields() {
+ public function test_um_after_password_reset_fields(): void {
$subject = $this->get_subject();
$expected = $subject->display_captcha( '', $subject::UM_MODE );
diff --git a/.tests/php/integration/UM/RegisterTest.php b/.tests/php/integration/UM/RegisterTest.php
index 319c9c5f..0d05efe9 100644
--- a/.tests/php/integration/UM/RegisterTest.php
+++ b/.tests/php/integration/UM/RegisterTest.php
@@ -30,10 +30,8 @@ class RegisterTest extends HCaptchaPluginWPTestCase {
*
* @return void
* @noinspection PhpUndefinedFunctionInspection
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
UM()->form()->errors = null;
parent::tearDown();
@@ -42,7 +40,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = $this->get_subject();
self::assertSame(
diff --git a/.tests/php/integration/WC/CheckoutTest.php b/.tests/php/integration/WC/CheckoutTest.php
index 7e988a9f..af383bc4 100644
--- a/.tests/php/integration/WC/CheckoutTest.php
+++ b/.tests/php/integration/WC/CheckoutTest.php
@@ -42,7 +42,7 @@ class CheckoutTest extends HCaptchaPluginWPTestCase {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
if ( did_action( 'woocommerce_init' ) ) {
wc_clear_notices();
}
@@ -56,7 +56,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Checkout();
self::assertSame(
@@ -84,7 +84,7 @@ public function test_constructor_and_init_hooks() {
/**
* Tests add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'action' => 'hcaptcha_wc_checkout',
'name' => 'hcaptcha_wc_checkout_nonce',
@@ -107,7 +107,7 @@ public function test_add_captcha() {
/**
* Tests add_captcha().
*/
- public function test_add_block_captcha() {
+ public function test_add_block_captcha(): void {
$content1 = 'some block content 1';
$checkout_block = '';
$content2 = 'some block content 2';
@@ -142,7 +142,7 @@ public function test_add_block_captcha() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_wc_checkout_nonce', 'hcaptcha_wc_checkout' );
WC()->init();
@@ -159,7 +159,7 @@ public function test_verify() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$expected = [
'error' => [
[
@@ -185,7 +185,7 @@ public function test_verify_not_verified() {
*
* @return void
*/
- public function test_verify_block() {
+ public function test_verify_block(): void {
$widget_id_name = 'hcaptcha-widget-id';
$hcaptcha_response_name = 'h-captcha-response';
$hcaptcha_response = 'some hcaptcha response';
@@ -225,7 +225,7 @@ public function test_verify_block() {
/**
* Test enqueue_scripts().
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
$subject = new Checkout();
self::assertFalse( wp_script_is( 'hcaptcha-wc-checkout' ) );
@@ -255,7 +255,7 @@ public function test_enqueue_scripts() {
/**
* Test enqueue_scripts() when captcha was NOT added.
*/
- public function test_enqueue_scripts_when_captcha_was_NOT_added() {
+ public function test_enqueue_scripts_when_captcha_was_NOT_added(): void {
$subject = new Checkout();
self::assertFalse( wp_script_is( 'hcaptcha-wc-checkout' ) );
diff --git a/.tests/php/integration/WC/LoginTest.php b/.tests/php/integration/WC/LoginTest.php
index dcbe182d..fd95d68f 100644
--- a/.tests/php/integration/WC/LoginTest.php
+++ b/.tests/php/integration/WC/LoginTest.php
@@ -24,11 +24,9 @@ class LoginTest extends HCaptchaWPTestCase {
/**
* Tear down the test.
*
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
* @throws ReflectionException ReflectionException.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
$this->set_protected_property( hcaptcha(), 'loaded_classes', [] );
parent::tearDown();
@@ -37,7 +35,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Login();
self::assertSame(
@@ -53,7 +51,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'action' => 'hcaptcha_login',
'name' => 'hcaptcha_login_nonce',
@@ -76,7 +74,7 @@ public function test_add_captcha() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$validation_error = new WP_Error();
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_login_nonce', 'hcaptcha_login' );
@@ -94,7 +92,7 @@ public function test_verify() {
/**
* Test verify() when not in the WC filter.
*/
- public function test_verify_NOT_wc_filter() {
+ public function test_verify_NOT_wc_filter(): void {
$validation_error = new WP_Error();
$subject = new Login();
@@ -105,7 +103,7 @@ public function test_verify_NOT_wc_filter() {
/**
* Test verify() when not login limit exceeded.
*/
- public function test_verify_NOT_login_limit_exceeded() {
+ public function test_verify_NOT_login_limit_exceeded(): void {
$validation_error = new WP_Error();
$subject = new Login();
@@ -128,7 +126,7 @@ static function () {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$validation_error = 'some wrong error, to be replaced by WP_Error';
$expected = new WP_Error();
$expected->add( 'hcaptcha_error', 'The hCaptcha is invalid.' );
@@ -149,8 +147,9 @@ public function test_verify_not_verified() {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/WC/LostPasswordTest.php b/.tests/php/integration/WC/LostPasswordTest.php
index 47418702..061528b6 100644
--- a/.tests/php/integration/WC/LostPasswordTest.php
+++ b/.tests/php/integration/WC/LostPasswordTest.php
@@ -22,7 +22,7 @@ class LostPasswordTest extends HCaptchaWPTestCase {
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new LostPassword();
self::assertSame(
@@ -34,7 +34,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'action' => 'hcaptcha_wc_lost_password',
'name' => 'hcaptcha_wc_lost_password_nonce',
@@ -58,8 +58,9 @@ public function test_add_captcha() {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/WC/OrderTrackingTest.php b/.tests/php/integration/WC/OrderTrackingTest.php
index aceffdc2..d80517a0 100644
--- a/.tests/php/integration/WC/OrderTrackingTest.php
+++ b/.tests/php/integration/WC/OrderTrackingTest.php
@@ -20,7 +20,7 @@ class OrderTrackingTest extends HCaptchaWPTestCase {
/**
* Test constructor and init hooks.
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new OrderTracking();
self::assertSame(
@@ -32,7 +32,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test do_shortcode_tag().
*/
- public function test_do_shortcode_tag() {
+ public function test_do_shortcode_tag(): void {
$site_key = 'some site key';
$theme = 'some theme';
$size = 'some size';
@@ -105,7 +105,7 @@ public function test_do_shortcode_tag() {
/**
* Test do_shortcode_tag() when not order_tracking tag.
*/
- public function test_do_shortcode_tag_when_NOT_order_tracking() {
+ public function test_do_shortcode_tag_when_NOT_order_tracking(): void {
$output = 'some output';
$tag = 'some_tag';
$subject = new OrderTracking();
diff --git a/.tests/php/integration/WC/RegisterTest.php b/.tests/php/integration/WC/RegisterTest.php
index f9b7ab7c..8966eba9 100644
--- a/.tests/php/integration/WC/RegisterTest.php
+++ b/.tests/php/integration/WC/RegisterTest.php
@@ -23,7 +23,7 @@ class RegisterTest extends HCaptchaWPTestCase {
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Register();
self::assertSame(
@@ -39,7 +39,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
hcaptcha()->init_hooks();
$args = [
@@ -64,7 +64,7 @@ public function test_add_captcha() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$validation_error = new WP_Error( 'some error' );
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_wc_register_nonce', 'hcaptcha_wc_register' );
@@ -76,7 +76,7 @@ public function test_verify() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$validation_error = 'some wrong error, to be replaced by WP_Error';
$expected = new WP_Error();
@@ -92,8 +92,9 @@ public function test_verify_not_verified() {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/WCWishlists/CreateListTest.php b/.tests/php/integration/WCWishlists/CreateListTest.php
index 208009d0..6ad47dc4 100644
--- a/.tests/php/integration/WCWishlists/CreateListTest.php
+++ b/.tests/php/integration/WCWishlists/CreateListTest.php
@@ -31,7 +31,7 @@ class CreateListTest extends HCaptchaPluginWPTestCase {
/**
* Test before_wrapper() and after_wrapper().
*/
- public function test_wrapper() {
+ public function test_wrapper(): void {
$row = '';
$expected =
"\n" .
@@ -65,7 +65,7 @@ public function test_wrapper() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$valid_captcha = 'some captcha';
$this->prepare_hcaptcha_get_verify_message( 'hcaptcha_wc_create_wishlists_nonce', 'hcaptcha_wc_create_wishlists_action' );
@@ -84,7 +84,7 @@ public function test_verify() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$valid_captcha = 'some captcha';
$expected = [
'error' => [
diff --git a/.tests/php/integration/WP/CommentTest.php b/.tests/php/integration/WP/CommentTest.php
index c5334956..92f2cf98 100644
--- a/.tests/php/integration/WP/CommentTest.php
+++ b/.tests/php/integration/WP/CommentTest.php
@@ -29,7 +29,7 @@ class CommentTest extends HCaptchaWPTestCase {
/**
* Tear down test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
unset( $GLOBALS['current_screen'] );
@@ -43,7 +43,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @dataProvider dp_test_constructor_and_init_hooks
*/
- public function test_constructor_and_init_hooks( bool $active ) {
+ public function test_constructor_and_init_hooks( bool $active ): void {
if ( $active ) {
update_option( 'hcaptcha_settings', [ 'wp_status' => 'comment' ] );
}
@@ -74,7 +74,7 @@ public function dp_test_constructor_and_init_hooks(): array {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$form_id = '1';
$submit_field =
'
' .
@@ -107,7 +107,7 @@ public function test_add_captcha() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_add_captcha_when_NOT_active() {
+ public function test_add_captcha_when_NOT_active(): void {
$form_id = '1';
$submit_field =
'
' .
@@ -136,7 +136,7 @@ public function test_add_captcha_when_NOT_active() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_verify() {
+ public function test_verify(): void {
$commentdata = [ 'some comment data' ];
$this->prepare_hcaptcha_get_verify_message_html( 'hcaptcha_comment_nonce', 'hcaptcha_comment' );
@@ -155,7 +155,7 @@ public function test_verify() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_verify_in_admin() {
+ public function test_verify_in_admin(): void {
$commentdata = [ 'some comment data' ];
set_current_screen( 'edit-post' );
@@ -171,7 +171,7 @@ public function test_verify_in_admin() {
*
* @throws ReflectionException ReflectionException.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$commentdata = [ 'some comment data' ];
$expected = 'hCaptcha error: The hCaptcha is invalid.';
@@ -188,7 +188,7 @@ public function test_verify_not_verified() {
*
* @return void
*/
- public function test_pre_comment_approved() {
+ public function test_pre_comment_approved(): void {
$approved = 1;
$commentdata = [ 'some comment data' ];
@@ -203,7 +203,7 @@ public function test_pre_comment_approved() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_pre_comment_approved_when_not_verified() {
+ public function test_pre_comment_approved_when_not_verified(): void {
$approved = 1;
$commentdata = [ 'some comment data' ];
$error_message = 'hCaptcha error: The hCaptcha is invalid.';
@@ -221,7 +221,7 @@ public function test_pre_comment_approved_when_not_verified() {
/**
* Test verify().
*/
- public function est_verify() {
+ public function est_verify(): void {
$approved = 1;
$commentdata = [ 'some comment data' ];
@@ -235,7 +235,7 @@ public function est_verify() {
/**
* Test verify() not verified in admin.
*/
- public function est_verify_not_verified_in_admin() {
+ public function est_verify_not_verified_in_admin(): void {
$approved = 1;
$commentdata = [ 'some comment data' ];
@@ -249,7 +249,7 @@ public function est_verify_not_verified_in_admin() {
/**
* Test verify() do not need to verify, not in admin.
*/
- public function est_verify_do_not_need_to_verify_not_admin() {
+ public function est_verify_do_not_need_to_verify_not_admin(): void {
$approved = 1;
$commentdata = [ 'some comment data' ];
$expected = new WP_Error( 'invalid_hcaptcha', 'hCaptcha error: Please complete the hCaptcha.', 400 );
@@ -262,7 +262,7 @@ public function est_verify_do_not_need_to_verify_not_admin() {
/**
* Test verify() not verified, not in admin.
*/
- public function est_verify_not_verified_not_admin() {
+ public function est_verify_not_verified_not_admin(): void {
$approved = 1;
$commentdata = [ 'some comment data' ];
$expected = new WP_Error( 'invalid_hcaptcha', 'hCaptcha error: The hCaptcha is invalid.', 400 );
diff --git a/.tests/php/integration/WP/LoginTest.php b/.tests/php/integration/WP/LoginTest.php
index 893c2ef7..9eca471a 100644
--- a/.tests/php/integration/WP/LoginTest.php
+++ b/.tests/php/integration/WP/LoginTest.php
@@ -26,11 +26,8 @@ class LoginTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset(
$_POST['log'],
@@ -47,7 +44,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Login();
self::assertSame(
@@ -61,7 +58,7 @@ public function test_constructor_and_init_hooks() {
*
* @return void
*/
- public function test_display_signature() {
+ public function test_display_signature(): void {
$subject = new Login();
$expected = $this->get_signature( get_class( $subject ) );
@@ -76,7 +73,7 @@ public function test_display_signature() {
*
* @return void
*/
- public function test_add_signature() {
+ public function test_add_signature(): void {
$content = 'some content';
$subject = new Login();
@@ -91,11 +88,11 @@ public function test_add_signature() {
*
* @return void
*/
- public function test_check_signature() {
+ public function test_check_signature(): void {
$user = wp_get_current_user();
$password = 'some password';
- FunctionMocker::replace( '\HCaptcha\Helpers\HCaptcha::check_signature', null );
+ FunctionMocker::replace( '\HCaptcha\Helpers\HCaptcha::check_signature' );
$this->prepare_hcaptcha_get_verify_message_html( 'hcaptcha_login_nonce', 'hcaptcha_login' );
@@ -115,7 +112,7 @@ public function test_check_signature() {
*
* @return void
*/
- public function test_check_signature_when_NOT_wp_login_form() {
+ public function test_check_signature_when_NOT_wp_login_form(): void {
$user = wp_get_current_user();
$password = 'some password';
@@ -129,7 +126,7 @@ public function test_check_signature_when_NOT_wp_login_form() {
*
* @return void
*/
- public function test_check_signature_when_good_signature() {
+ public function test_check_signature_when_good_signature(): void {
$user = wp_get_current_user();
$password = 'some password';
@@ -151,7 +148,7 @@ public function test_check_signature_when_good_signature() {
*
* @return void
*/
- public function test_check_signature_when_bad_signature() {
+ public function test_check_signature_when_bad_signature(): void {
$user = wp_get_current_user();
$password = 'some password';
@@ -174,7 +171,7 @@ public function test_check_signature_when_bad_signature() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_login() {
+ public function test_login(): void {
$ip = '1.1.1.1';
$login_data[ $ip ][] = time();
$login_data['2.2.2.2'][] = time();
@@ -205,7 +202,7 @@ public function test_login() {
* @throws ReflectionException ReflectionException.
* @noinspection UnusedFunctionResultInspection
*/
- public function test_login_failed() {
+ public function test_login_failed(): void {
$ip = '1.1.1.1';
$ip2 = '2.2.2.2';
$time = time();
@@ -233,7 +230,7 @@ public function test_login_failed() {
FunctionMocker::replace( 'time', $time );
- $subject->login_failed( $username, null );
+ $subject->login_failed( $username );
self::assertSame( $expected_login_data, $this->get_protected_property( $subject, 'login_data' ) );
self::assertSame( $expected_login_data, get_option( LoginBase::LOGIN_DATA ) );
@@ -242,7 +239,7 @@ public function test_login_failed() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
// phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
$GLOBALS['wp_actions']['login_init'] = 1;
$GLOBALS['wp_actions']['login_form_login'] = 1;
@@ -271,7 +268,7 @@ public function test_add_captcha() {
/**
* Test add_captcha() when not WP login form.
*/
- public function test_add_captcha_when_NOT_wp_login_form() {
+ public function test_add_captcha_when_NOT_wp_login_form(): void {
$expected = '';
$subject = new Login();
@@ -286,7 +283,7 @@ public function test_add_captcha_when_NOT_wp_login_form() {
/**
* Test add_captcha() when not login limit exceeded.
*/
- public function test_add_captcha_when_NOT_login_limit_exceeded() {
+ public function test_add_captcha_when_NOT_login_limit_exceeded(): void {
$expected = '';
$subject = new Login();
@@ -314,7 +311,7 @@ static function () {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$user = new WP_User( 1 );
$this->prepare_hcaptcha_get_verify_message_html( 'hcaptcha_login_nonce', 'hcaptcha_login' );
@@ -336,7 +333,7 @@ public function test_verify() {
/**
* Test verify() when login limit is not exceeded.
*/
- public function test_verify_NOT_limit_exceeded() {
+ public function test_verify_NOT_limit_exceeded(): void {
$user = new WP_User( 1 );
$this->prepare_hcaptcha_get_verify_message_html( 'hcaptcha_login_nonce', 'hcaptcha_login' );
@@ -360,7 +357,7 @@ public function test_verify_NOT_limit_exceeded() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$user = new WP_User( 1 );
$expected = new WP_Error( 'fail', 'The hCaptcha is invalid.', 400 );
diff --git a/.tests/php/integration/WP/LostPasswordTest.php b/.tests/php/integration/WP/LostPasswordTest.php
index 6f02e40d..0dd2d708 100644
--- a/.tests/php/integration/WP/LostPasswordTest.php
+++ b/.tests/php/integration/WP/LostPasswordTest.php
@@ -21,11 +21,8 @@ class LostPasswordTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_SERVER['REQUEST_URI'], $_GET['action'] );
@@ -35,7 +32,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new LostPassword();
self::assertSame(
@@ -51,7 +48,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$_SERVER['REQUEST_URI'] = '/wp-login.php';
$_GET['action'] = 'lostpassword';
@@ -77,7 +74,7 @@ public function test_add_captcha() {
/**
* Test add_captcha() when not WP login url.
*/
- public function test_add_captcha_when_NOT_wp_login_url() {
+ public function test_add_captcha_when_NOT_wp_login_url(): void {
unset( $_SERVER['REQUEST_URI'] );
$_GET['action'] = 'lostpassword';
@@ -96,7 +93,7 @@ public function test_add_captcha_when_NOT_wp_login_url() {
/**
* Test add_captcha() when not WP login action.
*/
- public function test_add_captcha_when_NOT_wp_login_action() {
+ public function test_add_captcha_when_NOT_wp_login_action(): void {
$_SERVER['REQUEST_URI'] = '/wp-login.php';
$expected = '';
@@ -113,7 +110,7 @@ public function test_add_captcha_when_NOT_wp_login_action() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$validation_error = new WP_Error( 'some error' );
$expected = clone $validation_error;
$_POST['wp-submit'] = 'some';
@@ -129,7 +126,7 @@ public function test_verify() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$validation_error = new WP_Error( 'some error' );
$expected = clone $validation_error;
$_POST['wp-submit'] = 'some';
@@ -147,7 +144,7 @@ public function test_verify_not_verified() {
/**
* Test verify() when not proper post key.
*/
- public function test_verify_when_NOT_proper_post_key() {
+ public function test_verify_when_NOT_proper_post_key(): void {
$validation_error = new WP_Error( 'some error' );
$expected = clone $validation_error;
diff --git a/.tests/php/integration/WP/PasswordProtectedTest.php b/.tests/php/integration/WP/PasswordProtectedTest.php
index 0e0b0235..604f4f61 100644
--- a/.tests/php/integration/WP/PasswordProtectedTest.php
+++ b/.tests/php/integration/WP/PasswordProtectedTest.php
@@ -9,8 +9,6 @@
use HCaptcha\Tests\Integration\HCaptchaWPTestCase;
use HCaptcha\WP\PasswordProtected;
-use HCaptcha\WP\Register;
-use WP_Error;
use WP_Post;
/**
@@ -23,11 +21,8 @@ class PasswordProtectedTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_SERVER['REQUEST_URI'], $_GET['action'] );
@@ -37,7 +32,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new PasswordProtected();
self::assertSame(
@@ -53,7 +48,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$_SERVER['REQUEST_URI'] = '/wp-login.php';
$_GET['action'] = 'register';
@@ -85,7 +80,7 @@ public function test_add_captcha() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$this->prepare_hcaptcha_verify_post( 'hcaptcha_password_protected_nonce', 'hcaptcha_password_protected' );
$subject = new PasswordProtected();
@@ -95,8 +90,9 @@ public function test_verify() {
/**
* Test verify() not verified.
- */
- public function test_verify_not_verified() {
+ *
+ * @noinspection PhpUnusedParameterInspection*/
+ public function test_verify_not_verified(): void {
$die_arr = [];
$expected = [
'The hCaptcha is invalid.',
diff --git a/.tests/php/integration/WP/RegisterTest.php b/.tests/php/integration/WP/RegisterTest.php
index 75fae407..3a42d7f7 100644
--- a/.tests/php/integration/WP/RegisterTest.php
+++ b/.tests/php/integration/WP/RegisterTest.php
@@ -21,11 +21,8 @@ class RegisterTest extends HCaptchaWPTestCase {
/**
* Tear down test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_SERVER['REQUEST_URI'], $_GET['action'] );
@@ -35,7 +32,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test constructor and init_hooks().
*/
- public function test_constructor_and_init_hooks() {
+ public function test_constructor_and_init_hooks(): void {
$subject = new Register();
self::assertSame(
@@ -51,7 +48,7 @@ public function test_constructor_and_init_hooks() {
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$_SERVER['REQUEST_URI'] = '/wp-login.php';
$_GET['action'] = 'register';
@@ -77,7 +74,7 @@ public function test_add_captcha() {
/**
* Test add_captcha() when not WP login url.
*/
- public function test_add_captcha_when_NOT_login_url() {
+ public function test_add_captcha_when_NOT_login_url(): void {
unset( $_SERVER['REQUEST_URI'] );
$_GET['action'] = 'register';
@@ -96,7 +93,7 @@ public function test_add_captcha_when_NOT_login_url() {
/**
* Test add_captcha() when not register action.
*/
- public function test_add_captcha_when_NOT_register_action() {
+ public function test_add_captcha_when_NOT_register_action(): void {
$_SERVER['REQUEST_URI'] = '/wp-login.php';
$_GET['action'] = 'some';
@@ -114,7 +111,7 @@ public function test_add_captcha_when_NOT_register_action() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$_GET['action'] = 'register';
$errors = new WP_Error( 'some error' );
@@ -129,7 +126,7 @@ public function test_verify() {
/**
* Test verify() not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$_GET['action'] = 'register';
$errors = new WP_Error( 'some error' );
@@ -146,7 +143,7 @@ public function test_verify_not_verified() {
/**
* Test verify() not register action.
*/
- public function test_verify_when_NOT_register_action() {
+ public function test_verify_when_NOT_register_action(): void {
$_GET['action'] = 'some';
$errors = new WP_Error( 'some error' );
diff --git a/.tests/php/integration/WPDiscuz/CommentTest.php b/.tests/php/integration/WPDiscuz/CommentTest.php
index 38fe3366..828c7005 100644
--- a/.tests/php/integration/WPDiscuz/CommentTest.php
+++ b/.tests/php/integration/WPDiscuz/CommentTest.php
@@ -23,10 +23,8 @@ class CommentTest extends HCaptchaWPTestCase {
* Tear down test.
*
* @return void
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST['h-captcha-response'], $_POST['g-recaptcha-response'] );
}
@@ -35,7 +33,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @return void
*/
- public function test_init_hooks() {
+ public function test_init_hooks(): void {
$subject = new Comment();
self::assertTrue( has_filter( 'wpdiscuz_recaptcha_site_key' ) );
@@ -53,7 +51,7 @@ public function test_init_hooks() {
*
* @return void
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
self::assertFalse( wp_script_is( 'wpdiscuz-google-recaptcha', 'registered' ) );
self::assertFalse( wp_script_is( 'wpdiscuz-google-recaptcha' ) );
@@ -81,7 +79,7 @@ public function test_enqueue_scripts() {
*
* @return void
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$args = [
'id' => [
'source' => [ 'wpdiscuz/class.WpdiscuzCore.php' ],
@@ -108,7 +106,7 @@ public function test_add_captcha() {
*
* @return void
*/
- public function test_verify() {
+ public function test_verify(): void {
$comment_data = [ 'some comment data' ];
$hcaptcha_response = 'some response';
@@ -130,8 +128,9 @@ public function test_verify() {
* Test verify() when not verified.
*
* @return void
+ * @noinspection PhpUnusedParameterInspection
*/
- public function test_verify_NOT_verified() {
+ public function test_verify_NOT_verified(): void {
$comment_data = [ 'some comment data' ];
$hcaptcha_response = 'some response';
$die_arr = [];
@@ -175,7 +174,7 @@ static function ( $name ) use ( &$die_arr ) {
*
* @return void
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
$expected = '.wpd-field-hcaptcha .h-captcha{margin-left:auto}';
$expected = "\n";
diff --git a/.tests/php/integration/WPDiscuz/SubscribeTest.php b/.tests/php/integration/WPDiscuz/SubscribeTest.php
index 8068b596..f4c02705 100644
--- a/.tests/php/integration/WPDiscuz/SubscribeTest.php
+++ b/.tests/php/integration/WPDiscuz/SubscribeTest.php
@@ -9,8 +9,6 @@
use HCaptcha\Tests\Integration\HCaptchaWPTestCase;
use HCaptcha\WPDiscuz\Subscribe;
-use Mockery;
-use tad\FunctionMocker\FunctionMocker;
/**
* Test Subscribe class.
@@ -23,10 +21,8 @@ class SubscribeTest extends HCaptchaWPTestCase {
* Tear down test.
*
* @return void
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST['h-captcha-response'], $_POST['g-recaptcha-response'] );
}
@@ -35,7 +31,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @return void
*/
- public function test_init_hooks() {
+ public function test_init_hooks(): void {
$subject = new Subscribe();
self::assertTrue( has_filter( 'wpdiscuz_recaptcha_site_key' ) );
@@ -54,7 +50,7 @@ public function test_init_hooks() {
*
* @return void
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
self::assertFalse( wp_script_is( 'wpdiscuz-google-recaptcha', 'registered' ) );
self::assertFalse( wp_script_is( 'wpdiscuz-google-recaptcha' ) );
@@ -82,7 +78,7 @@ public function test_enqueue_scripts() {
*
* @return void
*/
- public function test_add_hcaptcha() {
+ public function test_add_hcaptcha(): void {
$args = [
'id' => [
'source' => [ 'wpdiscuz/class.WpdiscuzCore.php' ],
@@ -105,7 +101,7 @@ public function test_add_hcaptcha() {
*
* @return void
*/
- public function test_verify() {
+ public function test_verify(): void {
$hcaptcha_response = 'some response';
$this->prepare_hcaptcha_request_verify( $hcaptcha_response );
@@ -123,7 +119,7 @@ public function test_verify() {
*
* @return void
*/
- public function test_verify_NOT_verified() {
+ public function test_verify_NOT_verified(): void {
$hcaptcha_response = 'some response';
$die_arr = [];
$expected = [
@@ -164,7 +160,7 @@ static function () use ( &$die_arr ) {
*
* @return void
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
$expected = '#wpdiscuz-subscribe-form .h-captcha{margin-top:5px;margin-left:auto}';
$expected = "\n";
diff --git a/.tests/php/integration/WPForms/FormTest.php b/.tests/php/integration/WPForms/FormTest.php
index e5b6c896..5cb1163c 100644
--- a/.tests/php/integration/WPForms/FormTest.php
+++ b/.tests/php/integration/WPForms/FormTest.php
@@ -39,7 +39,7 @@ class FormTest extends HCaptchaPluginWPTestCase {
* @return void
* @dataProvider dp_test_init_hooks
*/
- public function test_init_hooks( bool $mode_auto, bool $mode_embed ) {
+ public function test_init_hooks( bool $mode_auto, bool $mode_embed ): void {
$status = [];
if ( $mode_auto ) {
@@ -117,7 +117,7 @@ public function dp_test_init_hooks(): array {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$fields = [ 'some field' ];
$form_data = [ 'id' => 5 ];
@@ -140,7 +140,7 @@ public function test_verify() {
*
* @return void
*/
- public function test_verify_when_not_process_hcaptcha() {
+ public function test_verify_when_not_process_hcaptcha(): void {
$fields = [ 'some field' ];
$form_data = [ 'id' => 5 ];
@@ -156,7 +156,7 @@ public function test_verify_when_not_process_hcaptcha() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$fields = [ 'some field' ];
$form_data = [ 'id' => 5 ];
$expected = 'The hCaptcha is invalid.';
@@ -180,7 +180,7 @@ public function test_verify_not_verified() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified_with_wpforms_settings() {
+ public function test_verify_not_verified_with_wpforms_settings(): void {
$fields = [ 'some field' ];
$form_data = [
'id' => 5,
@@ -225,8 +225,9 @@ static function ( $value, $key ) use ( $wpforms_error_message ) {
* Test print_inline_styles().
*
* @return void
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
@@ -284,7 +285,7 @@ static function ( $name ) {
*
* @return void
*/
- public function test_wpforms_settings_fields() {
+ public function test_wpforms_settings_fields(): void {
$fields = [
'hcaptcha-heading' => '
Some hCaptcha heading
',
'hcaptcha-site-key' => '
',
@@ -336,7 +337,7 @@ class="wpforms-setting-row wpforms-setting-row-content wpforms-clear section-hea
*
* @return void
*/
- public function test_hcap_print_hcaptcha_scripts() {
+ public function test_hcap_print_hcaptcha_scripts(): void {
$subject = new Form();
// Not in admin.
@@ -378,7 +379,7 @@ static function ( $value, $key ) {
*
* @return void
*/
- public function test_wpforms_admin_settings_captcha_enqueues_disable() {
+ public function test_wpforms_admin_settings_captcha_enqueues_disable(): void {
$subject = new Form();
// Not in admin.
@@ -420,7 +421,7 @@ static function ( $value, $key ) {
*
* @return void
*/
- public function test_block_assets_recaptcha() {
+ public function test_block_assets_recaptcha(): void {
wpforms()->register(
[
'name' => 'Frontend\Captcha',
@@ -467,7 +468,7 @@ static function ( $value, $key ) {
*
* @return void
*/
- public function test_wpforms_frontend_output_when_not_processing_hcaptcha() {
+ public function test_wpforms_frontend_output_when_not_processing_hcaptcha(): void {
$form_data = [ 'id' => 5 ];
$deprecated = null;
$title = 'some title';
@@ -487,7 +488,7 @@ public function test_wpforms_frontend_output_when_not_processing_hcaptcha() {
*
* @return void
*/
- public function test_wpforms_frontend_output_when_mode_embed() {
+ public function test_wpforms_frontend_output_when_mode_embed(): void {
$form_id = 5;
$form_data = [
'id' => $form_id,
@@ -558,7 +559,7 @@ static function ( $value, $key ) {
*
* @return void
*/
- public function test_wpforms_frontend_output_when_mode_auto() {
+ public function test_wpforms_frontend_output_when_mode_auto(): void {
$form_id = 5;
$form_data = [ 'id' => $form_id ];
$deprecated = null;
@@ -608,7 +609,7 @@ public function test_wpforms_frontend_output_when_mode_auto() {
*
* @return void
*/
- public function test_wpforms_frontend_output_when_mode_auto_and_form_has_hcaptcha() {
+ public function test_wpforms_frontend_output_when_mode_auto_and_form_has_hcaptcha(): void {
$form_id = 5;
$form_data = [
'id' => $form_id,
@@ -685,7 +686,7 @@ static function ( $value, $key ) {
* @throws ReflectionException ReflectionException.
* @noinspection UnusedFunctionResultInspection
*/
- public function test_process_hcaptcha( bool $mode_auto, bool $mode_embed, bool $has_hcaptcha, bool $expected ) {
+ public function test_process_hcaptcha( bool $mode_auto, bool $mode_embed, bool $has_hcaptcha, bool $expected ): void {
$form_data = [ 'id' => 5 ];
$status = [];
$init_hooks = 'init_hooks';
diff --git a/.tests/php/integration/WPForo/NewTopicTest.php b/.tests/php/integration/WPForo/NewTopicTest.php
index fb666164..43b7bea1 100644
--- a/.tests/php/integration/WPForo/NewTopicTest.php
+++ b/.tests/php/integration/WPForo/NewTopicTest.php
@@ -38,7 +38,7 @@ class NewTopicTest extends HCaptchaPluginWPTestCase {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function setUp(): void {
set_current_screen( 'edit-post' );
parent::setUp();
@@ -51,7 +51,7 @@ public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclara
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
WPF()->session_token = '';
WPF()->notice->clear();
WPF()->session_token = '';
@@ -62,7 +62,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$topic = 2;
$args = [
'action' => 'hcaptcha_wpforo_new_topic',
@@ -86,7 +86,7 @@ public function test_add_captcha() {
/**
* Test verify().
*/
- public function test_verify() {
+ public function test_verify(): void {
$data = [ 'some data' ];
$subject = new NewTopic();
@@ -102,7 +102,7 @@ public function test_verify() {
/**
* Test verify() when not verified.
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$expected = 'The hCaptcha is invalid.
';
$subject = new NewTopic();
@@ -125,7 +125,7 @@ public function test_verify_not_verified() {
*
* @return void
*/
- public function test_print_hcaptcha_scripts() {
+ public function test_print_hcaptcha_scripts(): void {
$subject = new NewTopic();
self::assertFalse( $subject->print_hcaptcha_scripts( false ) );
@@ -142,7 +142,7 @@ public function test_print_hcaptcha_scripts() {
*
* @return void
*/
- public function test_enqueue_scripts() {
+ public function test_enqueue_scripts(): void {
$subject = new NewTopic();
self::assertFalse( wp_script_is( 'hcaptcha-wpforo' ) );
@@ -157,8 +157,9 @@ public function test_enqueue_scripts() {
*
* @return void
* @noinspection UnusedFunctionResultInspection
+ * @noinspection CssUnusedSymbol
*/
- public function test_print_inline_styles() {
+ public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
diff --git a/.tests/php/integration/WPForo/ReplyTest.php b/.tests/php/integration/WPForo/ReplyTest.php
index 1c781d34..bcb66c41 100644
--- a/.tests/php/integration/WPForo/ReplyTest.php
+++ b/.tests/php/integration/WPForo/ReplyTest.php
@@ -37,7 +37,7 @@ class ReplyTest extends HCaptchaPluginWPTestCase {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function setUp(): void {
set_current_screen( 'edit-post' );
parent::setUp();
@@ -50,7 +50,7 @@ public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclara
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
WPF()->session_token = '';
WPF()->notice->clear();
WPF()->session_token = '';
@@ -61,7 +61,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
/**
* Test add_captcha().
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$topic_id = 21;
$topic = [
'forumid' => 2,
@@ -92,7 +92,7 @@ public function test_add_captcha() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify() {
+ public function test_verify(): void {
$data = [ 'some data' ];
$subject = new Reply();
@@ -108,7 +108,7 @@ public function test_verify() {
*
* @noinspection PhpUndefinedFunctionInspection
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
$expected = 'The hCaptcha is invalid.
';
$subject = new Reply();
diff --git a/.tests/php/integration/WPJobOpenings/FormTest.php b/.tests/php/integration/WPJobOpenings/FormTest.php
index 631e84f9..ca4093b0 100644
--- a/.tests/php/integration/WPJobOpenings/FormTest.php
+++ b/.tests/php/integration/WPJobOpenings/FormTest.php
@@ -27,7 +27,7 @@ class FormTest extends HCaptchaWPTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $GLOBALS['awsm_response'] );
}
@@ -36,7 +36,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @return void
*/
- public function test_init_hooks() {
+ public function test_init_hooks(): void {
$subject = new Form();
self::assertSame( 10, has_action( 'before_awsm_application_form', [ $subject, 'before_application_form' ] ) );
@@ -49,7 +49,7 @@ public function test_init_hooks() {
*
* @return void
*/
- public function test_add_captcha() {
+ public function test_add_captcha(): void {
$form_id = 5;
$form_attrs = [
'job_id' => $form_id,
@@ -83,7 +83,7 @@ public function test_add_captcha() {
*
* @return void
*/
- public function test_verify() {
+ public function test_verify(): void {
global $awsm_response;
$awsm_response = [];
@@ -94,7 +94,7 @@ public function test_verify() {
$subject->verify();
- self::assertSame( $awsm_response, [] );
+ self::assertSame( [], $awsm_response );
}
/**
@@ -102,7 +102,7 @@ public function test_verify() {
*
* @return void
*/
- public function test_verify_not_verified() {
+ public function test_verify_not_verified(): void {
global $awsm_response;
$awsm_response = [];
@@ -113,6 +113,6 @@ public function test_verify_not_verified() {
$subject->verify();
- self::assertSame( $awsm_response, [ 'error' => [ 'The hCaptcha is invalid.' ] ] );
+ self::assertSame( [ 'error' => [ 'The hCaptcha is invalid.' ] ], $awsm_response );
}
}
diff --git a/.tests/php/integration/Wordfence/GeneralTest.php b/.tests/php/integration/Wordfence/GeneralTest.php
index 468b11aa..c95e758b 100644
--- a/.tests/php/integration/Wordfence/GeneralTest.php
+++ b/.tests/php/integration/Wordfence/GeneralTest.php
@@ -30,7 +30,7 @@ class GeneralTest extends HCaptchaWPTestCase {
* @param string $wordfence_status Wordfence status.
* @dataProvider dp_test_init_hooks
*/
- public function test_init_hooks( string $wordfence_status ) {
+ public function test_init_hooks( string $wordfence_status ): void {
if ( 'login' === $wordfence_status ) {
update_option(
'hcaptcha_settings',
@@ -70,7 +70,7 @@ public function dp_test_init_hooks(): array {
*
* @return void
*/
- public function test_remove_wordfence_recaptcha_script() {
+ public function test_remove_wordfence_recaptcha_script(): void {
$handle = 'wordfence-ls-recaptcha';
wp_enqueue_script(
@@ -95,7 +95,7 @@ public function test_remove_wordfence_recaptcha_script() {
*
* @return void
*/
- public function test_block_wordfence_recaptcha() {
+ public function test_block_wordfence_recaptcha(): void {
$subject = new General();
self::assertFalse( $subject->block_wordfence_recaptcha() );
@@ -107,7 +107,7 @@ public function test_block_wordfence_recaptcha() {
* @return void
* @throws ReflectionException ReflectionException.
*/
- public function test_remove_wp_login_hcaptcha_hooks() {
+ public function test_remove_wp_login_hcaptcha_hooks(): void {
$subject = new General();
$subject->remove_wp_login_hcaptcha_hooks();
diff --git a/.tests/php/integration/includes/FunctionsTest.php b/.tests/php/integration/includes/FunctionsTest.php
index 96a3fe97..ce161e99 100644
--- a/.tests/php/integration/includes/FunctionsTest.php
+++ b/.tests/php/integration/includes/FunctionsTest.php
@@ -25,7 +25,7 @@ class FunctionsTest extends HCaptchaWPTestCase {
*
* @dataProvider dp_test_hcap_shortcode
*/
- public function test_hcap_shortcode( string $action, string $name, string $auto ) {
+ public function test_hcap_shortcode( string $action, string $name, string $auto ): void {
$filtered = ' filtered ';
$form_action = empty( $action ) ? 'hcaptcha_action' : $action;
diff --git a/.tests/php/integration/includes/RequestTest.php b/.tests/php/integration/includes/RequestTest.php
index 46188cb8..1790edd9 100644
--- a/.tests/php/integration/includes/RequestTest.php
+++ b/.tests/php/integration/includes/RequestTest.php
@@ -8,7 +8,6 @@
namespace HCaptcha\Tests\Integration\includes;
use HCaptcha\Tests\Integration\HCaptchaWPTestCase;
-use tad\FunctionMocker\FunctionMocker;
/**
* Test request file.
@@ -19,11 +18,8 @@ class RequestTest extends HCaptchaWPTestCase {
/**
* Tear down the test.
- *
- * @noinspection PhpLanguageLevelInspection
- * @noinspection PhpUndefinedClassInspection
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset(
$_SERVER['HTTP_TRUE_CLIENT_IP'],
$_SERVER['HTTP_CF_CONNECTING_IP'],
@@ -49,7 +45,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl
*
* @dataProvider dp_test_hcap_get_user_ip
*/
- public function test_hcap_get_user_ip( array $headers, $expected ) {
+ public function test_hcap_get_user_ip( array $headers, $expected ): void {
unset(
$_SERVER['HTTP_TRUE_CLIENT_IP'],
$_SERVER['HTTP_CF_CONNECTING_IP'],
@@ -150,7 +146,7 @@ public function dp_test_hcap_get_user_ip(): array {
*
* @return void
*/
- public function test_hcap_get_error_message() {
+ public function test_hcap_get_error_message(): void {
self::assertSame( '', hcap_get_error_message( 'wrong-error-code' ) );
self::assertSame(
'hCaptcha error: The request is invalid or malformed.',
@@ -165,7 +161,7 @@ public function test_hcap_get_error_message() {
/**
* Test hcaptcha_request_verify().
*/
- public function test_hcaptcha_request_verify() {
+ public function test_hcaptcha_request_verify(): void {
$hcaptcha_response = 'some response';
$this->prepare_hcaptcha_request_verify( $hcaptcha_response );
@@ -176,7 +172,7 @@ public function test_hcaptcha_request_verify() {
/**
* Test hcaptcha_request_verify() when protection is not enabled.
*/
- public function test_hcaptcha_request_verify_when_protection_not_enabled() {
+ public function test_hcaptcha_request_verify_when_protection_not_enabled(): void {
$hcaptcha_response = 'some response';
add_filter( 'hcap_protect_form', '__return_false' );
@@ -187,7 +183,7 @@ public function test_hcaptcha_request_verify_when_protection_not_enabled() {
/**
* Test hcaptcha_request_verify() with empty string as argument.
*/
- public function test_hcaptcha_request_verify_empty() {
+ public function test_hcaptcha_request_verify_empty(): void {
self::assertSame(
'Please complete the hCaptcha.',
hcaptcha_request_verify( '' )
@@ -197,7 +193,7 @@ public function test_hcaptcha_request_verify_empty() {
/**
* Test hcaptcha_request_verify() not verified.
*/
- public function test_hcaptcha_request_verify_not_verified() {
+ public function test_hcaptcha_request_verify_not_verified(): void {
$hcaptcha_response = 'some response';
$this->prepare_hcaptcha_request_verify( $hcaptcha_response, false );
@@ -208,7 +204,7 @@ public function test_hcaptcha_request_verify_not_verified() {
/**
* Test hcaptcha_request_verify() not verified with empty body.
*/
- public function test_hcaptcha_request_verify_not_verified_empty_body() {
+ public function test_hcaptcha_request_verify_not_verified_empty_body(): void {
$hcaptcha_response = 'some response';
$this->prepare_hcaptcha_request_verify( $hcaptcha_response, null );
@@ -219,7 +215,7 @@ public function test_hcaptcha_request_verify_not_verified_empty_body() {
/**
* Test hcaptcha_verify_POST() with no argument.
*/
- public function test_hcaptcha_verify_POST_default_success() {
+ public function test_hcaptcha_verify_POST_default_success(): void {
$hcaptcha_response = 'some response';
$this->prepare_hcaptcha_request_verify( $hcaptcha_response );
@@ -230,14 +226,14 @@ public function test_hcaptcha_verify_POST_default_success() {
/**
* Test hcaptcha_verify_POST() with no argument.
*/
- public function test_hcaptcha_verify_POST_default_empty() {
+ public function test_hcaptcha_verify_POST_default_empty(): void {
self::assertSame( 'Please complete the hCaptcha.', hcaptcha_verify_post() );
}
/**
* Test hcaptcha_verify_POST().
*/
- public function test_hcaptcha_verify_POST() {
+ public function test_hcaptcha_verify_POST(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -257,7 +253,7 @@ public function test_hcaptcha_verify_POST() {
/**
* Test hcaptcha_verify_POST() not verified.
*/
- public function test_hcaptcha_verify_POST_not_verified() {
+ public function test_hcaptcha_verify_POST_not_verified(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -269,7 +265,7 @@ public function test_hcaptcha_verify_POST_not_verified() {
/**
* Test hcaptcha_verify_POST() not verified with empty POST.
*/
- public function test_hcaptcha_verify_POST_not_verified_empty_POST() {
+ public function test_hcaptcha_verify_POST_not_verified_empty_POST(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -281,7 +277,7 @@ public function test_hcaptcha_verify_POST_not_verified_empty_POST() {
/**
* Test hcaptcha_verify_POST() not verified with logged-in user.
*/
- public function test_hcaptcha_verify_POST_not_verified_logged_in() {
+ public function test_hcaptcha_verify_POST_not_verified_logged_in(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -296,7 +292,7 @@ public function test_hcaptcha_verify_POST_not_verified_logged_in() {
/**
* Test hcaptcha_get_verify_output().
*/
- public function test_hcaptcha_get_verify_output() {
+ public function test_hcaptcha_get_verify_output(): void {
$empty_message = '';
$fail_message = '';
$nonce_field_name = 'some nonce field';
@@ -310,7 +306,7 @@ public function test_hcaptcha_get_verify_output() {
/**
* Test hcaptcha_get_verify_output() not validated.
*/
- public function test_hcaptcha_get_verify_output_not_validated() {
+ public function test_hcaptcha_get_verify_output_not_validated(): void {
$empty_message = '';
$fail_message = '';
$nonce_field_name = 'some nonce field';
@@ -324,7 +320,7 @@ public function test_hcaptcha_get_verify_output_not_validated() {
/**
* Test hcaptcha_get_verify_output() not validated with empty_POST.
*/
- public function test_hcaptcha_get_verify_output_not_validated_empty_POST() {
+ public function test_hcaptcha_get_verify_output_not_validated_empty_POST(): void {
$empty_message = '';
$fail_message = '';
$nonce_field_name = 'some nonce field';
@@ -338,7 +334,7 @@ public function test_hcaptcha_get_verify_output_not_validated_empty_POST() {
/**
* Test hcaptcha_get_verify_message().
*/
- public function test_hcaptcha_get_verify_message() {
+ public function test_hcaptcha_get_verify_message(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -350,7 +346,7 @@ public function test_hcaptcha_get_verify_message() {
/**
* Test hcaptcha_get_verify_message() not validated.
*/
- public function test_hcaptcha_get_verify_message_not_validated() {
+ public function test_hcaptcha_get_verify_message_not_validated(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -362,7 +358,7 @@ public function test_hcaptcha_get_verify_message_not_validated() {
/**
* Test hcaptcha_get_verify_message() not validated with empty POST.
*/
- public function test_hcaptcha_get_verify_message_not_validated_empty_POST() {
+ public function test_hcaptcha_get_verify_message_not_validated_empty_POST(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -374,7 +370,7 @@ public function test_hcaptcha_get_verify_message_not_validated_empty_POST() {
/**
* Test hcaptcha_get_verify_message_html().
*/
- public function test_hcaptcha_get_verify_message_html() {
+ public function test_hcaptcha_get_verify_message_html(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -386,7 +382,7 @@ public function test_hcaptcha_get_verify_message_html() {
/**
* Test hcaptcha_get_verify_message_html() not validated.
*/
- public function test_hcaptcha_get_verify_message_html_not_validated() {
+ public function test_hcaptcha_get_verify_message_html_not_validated(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
@@ -401,7 +397,7 @@ public function test_hcaptcha_get_verify_message_html_not_validated() {
/**
* Test hcaptcha_get_verify_message_html() not validated with empty POST.
*/
- public function test_hcaptcha_get_verify_message_html_not_validated_empty_POST() {
+ public function test_hcaptcha_get_verify_message_html_not_validated_empty_POST(): void {
$nonce_field_name = 'some nonce field';
$nonce_action_name = 'some nonce action';
diff --git a/.tests/php/unit/AutoVerify/AutoVerifyTest.php b/.tests/php/unit/AutoVerify/AutoVerifyTest.php
index 665df53c..3a65de09 100644
--- a/.tests/php/unit/AutoVerify/AutoVerifyTest.php
+++ b/.tests/php/unit/AutoVerify/AutoVerifyTest.php
@@ -30,7 +30,7 @@ class AutoVerifyTest extends HCaptchaTestCase {
/**
* Tear down test.
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], $_POST );
diff --git a/.tests/php/unit/HCaptchaTestCase.php b/.tests/php/unit/HCaptchaTestCase.php
index 9994e3e4..786c21dc 100644
--- a/.tests/php/unit/HCaptchaTestCase.php
+++ b/.tests/php/unit/HCaptchaTestCase.php
@@ -30,7 +30,7 @@ abstract class HCaptchaTestCase extends TestCase {
/**
* Setup test
*/
- public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function setUp(): void {
FunctionMocker::setUp();
parent::setUp();
WP_Mock::setUp();
@@ -39,7 +39,7 @@ public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclara
/**
* End test
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
WP_Mock::tearDown();
Mockery::close();
parent::tearDown();
diff --git a/.tests/php/unit/Settings/GeneralTest.php b/.tests/php/unit/Settings/GeneralTest.php
index c22402b4..60c45453 100644
--- a/.tests/php/unit/Settings/GeneralTest.php
+++ b/.tests/php/unit/Settings/GeneralTest.php
@@ -39,7 +39,7 @@ class GeneralTest extends HCaptchaTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $_POST );
parent::tearDown();
diff --git a/.tests/php/unit/Settings/SystemInfoTest.php b/.tests/php/unit/Settings/SystemInfoTest.php
index 15bfbd05..71726f06 100644
--- a/.tests/php/unit/Settings/SystemInfoTest.php
+++ b/.tests/php/unit/Settings/SystemInfoTest.php
@@ -41,7 +41,7 @@ class SystemInfoTest extends HCaptchaTestCase {
*
* @return void
*/
- public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
+ public function tearDown(): void {
unset( $GLOBALS['wpdb'], $_SERVER['SERVER_SOFTWARE'], $_SESSION );
parent::tearDown();