diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index ff837b85..35666a24 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -162,6 +162,10 @@ jobs: wp: 'trunk' experimental: true + - php: '7.4' + wp: '6.2' + experimental: false + - php: '8.3' wp: 'trunk' experimental: true diff --git a/inc/functions.php b/inc/functions.php index d8dd6bb4..e94c052a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -120,8 +120,7 @@ function preferred_languages_get_locale_switcher_user_id() { /* @var WP_Locale_Switcher $wp_locale_switcher */ global $wp_locale_switcher; - return $wp_locale_switcher instanceof WP_Locale_Switcher && - method_exists( $wp_locale_switcher, 'get_switched_user_id' ) ? + return $wp_locale_switcher instanceof WP_Locale_Switcher ? $wp_locale_switcher->get_switched_user_id() : false; } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a34e37c3..ca08de3a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -8,8 +8,6 @@ parameters: ignoreErrors: - message: '/^Call to private\/internal function preferred_languages_load_just_in_time\(\)\.$/' - message: '/has no return type specified\.$/' - # See https://github.com/swissspidy/preferred-languages/issues/962. - - message: '/^Call to function method_exists\(\) with WP_Locale_Switcher and .get_switched_user_id. will always evaluate to true\.$/' - message: '/^Call to method PHPUnit\\Framework\\Assert::assertFalse\(\) with false will always evaluate to true\.$/' - message: '/^Cannot access offset 1 on mixed\.$/' - message: '/^Cannot access offset .messages. on mixed\.$/' diff --git a/preferred-languages.php b/preferred-languages.php index 72624314..d0427459 100644 --- a/preferred-languages.php +++ b/preferred-languages.php @@ -9,7 +9,7 @@ * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Text Domain: preferred-languages - * Requires at least: 6.1 + * Requires at least: 6.2 * Requires PHP: 7.0 * * Copyright (c) 2017 Pascal Birchler (email: swissspidy@chat.wordpress.org) diff --git a/tests/phpunit/tests/plugin.php b/tests/phpunit/tests/plugin.php index 77a97a9c..7c9f2f5f 100644 --- a/tests/phpunit/tests/plugin.php +++ b/tests/phpunit/tests/plugin.php @@ -170,10 +170,6 @@ public function test_get_locale_switcher_user_id_default() { * @covers ::preferred_languages_get_locale_switcher_user_id */ public function test_get_locale_switcher_user_id_switched() { - if ( ! function_exists( 'switch_to_user_locale' ) ) { - $this->markTestSkipped( 'This test requires WordPress 6.2 and switch_to_user_locale() to be available' ); - } - update_user_meta( self::$administrator, 'locale', 'de_DE' ); switch_to_user_locale( self::$administrator ); @@ -401,10 +397,6 @@ public function test_get_list_admin_fallback() { * @covers ::preferred_languages_get_list */ public function test_get_list_user_locale_switching() { - if ( ! function_exists( 'switch_to_user_locale' ) ) { - $this->markTestSkipped( 'This test requires WordPress 6.2 and switch_to_user_locale() to be available' ); - } - update_user_meta( self::$administrator, 'preferred_languages', 'de_DE,es_ES' ); switch_to_user_locale( self::$administrator );