Skip to content

Commit 0f9f837

Browse files
authored
Merge pull request #206 from codebtech/feat/wp-6.8-upgrade
feat: fixes lint errors from latest phpcs config
2 parents bdc1edb + 63198d6 commit 0f9f837

File tree

17 files changed

+1780
-717
lines changed

17 files changed

+1780
-717
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Stable tag: 0.3.2
99
Requires at least: 6.2
10-
Tested up to: 6.6
10+
Tested up to: 6.8
1111
Requires PHP: 8.1
1212

1313
WordPress Feature flags plugin allow developers to configure features in plugins/themes behind the feature flags on both

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
},
99
"require-dev": {
1010
"brain/monkey": "^2.6",
11-
"newsuk/nuk-wp-phpcs-config": "^0.2.0",
12-
"newsuk/nuk-wp-phpmd-config": "^0.1.0",
13-
"newsuk/nuk-wp-phpstan-config": "^0.1.0",
1411
"phpunit/phpunit": "^9.4",
15-
"yoast/wp-test-utils": "^1.2"
12+
"yoast/wp-test-utils": "^1.2",
13+
"squizlabs/php_codesniffer": "^3.7",
14+
"m0hanraj/phpcs-config": "0.2.1",
15+
"m0hanraj/phpstan-config": "0.1.0",
16+
"m0hanraj/phpmd-config": "0.1.0"
1617
},
1718
"autoload": {
1819
"psr-4": {
@@ -29,7 +30,8 @@
2930
"config": {
3031
"allow-plugins": {
3132
"dealerdirect/phpcodesniffer-composer-installer": true,
32-
"phpstan/extension-installer": true
33+
"phpstan/extension-installer": true,
34+
"ergebnis/composer-normalize": true
3335
},
3436
"platform": {
3537
"php": "8.1"

composer.lock

Lines changed: 1369 additions & 539 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/Flag.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class Flag {
2929
/**
3030
* Check if given feature is enabled or not.
3131
*
32+
* @since 0.1.0
33+
*
3234
* @param string $flag name of the flag.
3335
* @return bool
34-
* @since 0.1.0
3536
*/
3637
public static function is_enabled( string $flag ): bool {
3738
$flags = get_option( self::$option_name, [] );

includes/Helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ class Helper {
2121
/**
2222
* Flag search helper, returns true if flag is found and enabled.
2323
*
24+
* @since 0.1.0
25+
*
2426
* @param array<int, array{id: int, name: string, enabled: bool}> $flags flags array.
2527
* @param string $field field to search.
2628
* @param string $flag name of the flag.
2729
* @return boolean
28-
* @since 0.1.0
2930
*/
3031
public function search_flag( $flags, $field, $flag ) {
3132

includes/Settings.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ class Settings {
2121
/**
2222
* Register feature flag settings page.
2323
*
24-
* @return void
2524
* @since 0.1.0
25+
*
26+
* @return void
2627
*/
2728
public function register_feature_settings() {
2829
add_action( 'admin_menu', [ $this, 'register_settings' ] );
@@ -31,8 +32,9 @@ public function register_feature_settings() {
3132
/**
3233
* Register settings action method.
3334
*
34-
* @return void
3535
* @since 0.1.0
36+
*
37+
* @return void
3638
*/
3739
public function register_settings() {
3840

phpcs.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
2-
<ruleset name="NewsUK WP PHPCS Rules">
3-
<rule ref="NewsUK"/>
2+
<ruleset name="WP PHPCS Rules">
3+
<rule ref="WPDev"/>
44
<rule ref="WordPress.WP.I18n">
55
<properties>
66
<property name="text_domain" type="array">

phpmd.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0"?>
22
<ruleset>
3-
<rule ref="vendor/newsuk/nuk-wp-phpmd-config/ruleset.xml" />
3+
<rule ref="vendor/m0hanraj/phpmd-config/ruleset.xml" />
44
</ruleset>

plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* The plugin bootstrap file
44
*
5-
* @since 0.1.0
65
* @package codeb-feature-flags
6+
* @since 0.1.0
77
*
88
* @wordpress-plugin
99
* Plugin Name: Feature Flags

tests/integration/FlagTest.php

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,70 @@
22
use CodeB\FeatureFlags\Flag;
33
use Yoast\WPTestUtils\WPIntegration\TestCase;
44

5-
class FlagTest extends TestCase{
5+
class FlagTest extends TestCase {
66

77
public function test_is_enabled_returns_true_if_flags_exists_and_enabled(): void {
88
// Set up test data
9-
$optionValue = [['id' => 1, 'name' => 'test', 'enabled' => true ]];
10-
update_option(Flag::$option_name, $optionValue);
11-
12-
$result = Flag::is_enabled('test');
13-
14-
$this->assertTrue($result);
9+
$option_value = [
10+
[
11+
'id' => 1,
12+
'name' => 'test',
13+
'enabled' => true,
14+
],
15+
];
16+
update_option( Flag::$option_name, $option_value );
17+
18+
$result = Flag::is_enabled( 'test' );
19+
20+
$this->assertTrue( $result );
1521
}
1622

1723
public function test_is_enabled_returns_false_if_flags_exists_and_disabled(): void {
1824
// Set up test data
19-
$optionValue = [['id' => 1, 'name' => 'test', 'enabled' => false ]];
20-
update_option(Flag::$option_name, $optionValue);
21-
22-
$result = Flag::is_enabled('test');
23-
24-
$this->assertFalse($result);
25+
$option_value = [
26+
[
27+
'id' => 1,
28+
'name' => 'test',
29+
'enabled' => false,
30+
],
31+
];
32+
update_option( Flag::$option_name, $option_value );
33+
34+
$result = Flag::is_enabled( 'test' );
35+
36+
$this->assertFalse( $result );
2537
}
2638

2739
public function test_is_enabled_returns_false_if_flags_not_exists(): void {
2840
// Set up test data
29-
$optionValue = [['id' => 1, 'name' => 'test2', 'enabled' => true ]];
30-
update_option(Flag::$option_name, $optionValue);
31-
32-
$result = Flag::is_enabled('test');
33-
34-
$this->assertFalse($result);
41+
$option_value = [
42+
[
43+
'id' => 1,
44+
'name' => 'test2',
45+
'enabled' => true,
46+
],
47+
];
48+
update_option( Flag::$option_name, $option_value );
49+
50+
$result = Flag::is_enabled( 'test' );
51+
52+
$this->assertFalse( $result );
3553
}
3654

3755
public function test_is_enabled_returns_false_if_option_is_empty(): void {
3856
// Set up test data
39-
$optionValue = [];
40-
update_option(Flag::$option_name, $optionValue);
57+
$option_value = [];
58+
update_option( Flag::$option_name, $option_value );
4159

42-
$result = Flag::is_enabled('test');
60+
$result = Flag::is_enabled( 'test' );
4361

44-
$this->assertFalse($result);
62+
$this->assertFalse( $result );
4563
}
4664

4765
public function test_is_enabled_returns_false_if_option_not_exists(): void {
4866

49-
$result = Flag::is_enabled('test');
67+
$result = Flag::is_enabled( 'test' );
5068

51-
$this->assertFalse($result);
69+
$this->assertFalse( $result );
5270
}
5371
}

0 commit comments

Comments
 (0)