Skip to content

Commit 13532b6

Browse files
add phpcs
1 parent 5a9be96 commit 13532b6

38 files changed

+3643
-3520
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ charset = utf-8
1111
end_of_line = lf
1212
insert_final_newline = true
1313
trim_trailing_whitespace = true
14-
indent_style = tab
14+
indent_style = space
15+
indent_size = 4
1516

1617
[*.{yml,yaml}]
1718
indent_style = space

.github/workflows/php-run-tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717

1818
- name: checkout repo
1919
uses: actions/checkout@v3
20-
2120
- run: composer install --no-progress
22-
- run: ./vendor/bin/phpunit
21+
22+
- name: PHPCodeSniffer
23+
run: ./vendor/bin/phpcs -ns
24+
25+
- name: PHPUnit
26+
run: ./vendor/bin/phpunit

boxzilla.php

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
Plugin Name: Boxzilla
45
Version: 3.4.0
@@ -35,53 +36,53 @@
3536
// Exit if PHP lower than 7.2
3637
PHP_VERSION_ID >= 70200 or exit;
3738

38-
define( 'BOXZILLA_FILE', __FILE__ );
39-
define( 'BOXZILLA_DIR', __DIR__ );
40-
define( 'BOXZILLA_VERSION', '3.3.1' );
39+
define('BOXZILLA_FILE', __FILE__);
40+
define('BOXZILLA_DIR', __DIR__);
41+
define('BOXZILLA_VERSION', '3.3.1');
4142

4243
require __DIR__ . '/autoload.php';
4344
require __DIR__ . '/src/services.php';
4445
require __DIR__ . '/src/licensing/services.php';
4546

4647

4748
// register activation hook
48-
register_activation_hook( __FILE__, array( 'Boxzilla\\Admin\\Installer', 'run' ) );
49+
register_activation_hook(__FILE__, [ 'Boxzilla\\Admin\\Installer', 'run' ]);
4950

5051
// Bootstrap plugin at later action hook
5152
add_action(
52-
'plugins_loaded',
53-
function() {
54-
$boxzilla = boxzilla();
55-
56-
// load default filters
57-
require __DIR__ . '/src/default-filters.php';
58-
require __DIR__ . '/src/default-actions.php';
59-
60-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
61-
$boxzilla['filter.autocomplete']->init();
62-
$boxzilla['admin.menu']->init();
63-
} elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) {
64-
$boxzilla['license_poller']->init();
65-
} elseif ( is_admin() ) {
66-
$boxzilla['admin']->init();
67-
$boxzilla['admin.menu']->init();
68-
} else {
69-
add_action(
70-
'template_redirect',
71-
function() use ( $boxzilla ) {
72-
$boxzilla['box_loader']->init();
73-
}
74-
);
75-
}
76-
77-
// license manager
78-
if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
79-
$boxzilla['license_manager']->init();
80-
81-
if ( count( $boxzilla->plugins ) > 0 ) {
82-
$boxzilla['update_manager']->init();
83-
}
84-
}
85-
},
86-
90
53+
'plugins_loaded',
54+
function () {
55+
$boxzilla = boxzilla();
56+
57+
// load default filters
58+
require __DIR__ . '/src/default-filters.php';
59+
require __DIR__ . '/src/default-actions.php';
60+
61+
if (defined('DOING_AJAX') && DOING_AJAX) {
62+
$boxzilla['filter.autocomplete']->init();
63+
$boxzilla['admin.menu']->init();
64+
} elseif (defined('DOING_CRON') && DOING_CRON) {
65+
$boxzilla['license_poller']->init();
66+
} elseif (is_admin()) {
67+
$boxzilla['admin']->init();
68+
$boxzilla['admin.menu']->init();
69+
} else {
70+
add_action(
71+
'template_redirect',
72+
function () use ($boxzilla) {
73+
$boxzilla['box_loader']->init();
74+
}
75+
);
76+
}
77+
78+
// license manager
79+
if (is_admin() || ( defined('DOING_CRON') && DOING_CRON ) || ( defined('WP_CLI') && WP_CLI )) {
80+
$boxzilla['license_manager']->init();
81+
82+
if (count($boxzilla->plugins) > 0) {
83+
$boxzilla['update_manager']->init();
84+
}
85+
}
86+
},
87+
90
8788
);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"php": ">=7.4"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^10.5.40"
24+
"phpunit/phpunit": "^10.5.40",
25+
"squizlabs/php_codesniffer": "^3.11"
2526
},
2627
"scripts": {
2728
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -print0 | xargs -0 -n1 php -l"

phpcs.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="rules">
3+
<description>rules</description>
4+
<arg name="colors"/>
5+
<file>src/</file>
6+
<file>boxzilla.php</file>
7+
<exclude-pattern>*\.(html|css|js)</exclude-pattern>
8+
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>
9+
<rule ref="PSR12">
10+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
11+
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
12+
</rule>
13+
</ruleset>

0 commit comments

Comments
 (0)