Skip to content

Commit

Permalink
add phpcs
Browse files Browse the repository at this point in the history
dannyvankooten committed Jan 11, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5a9be96 commit 13532b6
Showing 38 changed files with 3,643 additions and 3,520 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_style = space
8 changes: 6 additions & 2 deletions .github/workflows/php-run-tests.yml
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@ jobs:

- name: checkout repo
uses: actions/checkout@v3

- run: composer install --no-progress
- run: ./vendor/bin/phpunit

- name: PHPCodeSniffer
run: ./vendor/bin/phpcs -ns

- name: PHPUnit
run: ./vendor/bin/phpunit
79 changes: 40 additions & 39 deletions boxzilla.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
Plugin Name: Boxzilla
Version: 3.4.0
@@ -35,53 +36,53 @@
// Exit if PHP lower than 7.2
PHP_VERSION_ID >= 70200 or exit;

define( 'BOXZILLA_FILE', __FILE__ );
define( 'BOXZILLA_DIR', __DIR__ );
define( 'BOXZILLA_VERSION', '3.3.1' );
define('BOXZILLA_FILE', __FILE__);
define('BOXZILLA_DIR', __DIR__);
define('BOXZILLA_VERSION', '3.3.1');

require __DIR__ . '/autoload.php';
require __DIR__ . '/src/services.php';
require __DIR__ . '/src/licensing/services.php';


// register activation hook
register_activation_hook( __FILE__, array( 'Boxzilla\\Admin\\Installer', 'run' ) );
register_activation_hook(__FILE__, [ 'Boxzilla\\Admin\\Installer', 'run' ]);

// Bootstrap plugin at later action hook
add_action(
'plugins_loaded',
function() {
$boxzilla = boxzilla();

// load default filters
require __DIR__ . '/src/default-filters.php';
require __DIR__ . '/src/default-actions.php';

if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
$boxzilla['filter.autocomplete']->init();
$boxzilla['admin.menu']->init();
} elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) {
$boxzilla['license_poller']->init();
} elseif ( is_admin() ) {
$boxzilla['admin']->init();
$boxzilla['admin.menu']->init();
} else {
add_action(
'template_redirect',
function() use ( $boxzilla ) {
$boxzilla['box_loader']->init();
}
);
}

// license manager
if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
$boxzilla['license_manager']->init();

if ( count( $boxzilla->plugins ) > 0 ) {
$boxzilla['update_manager']->init();
}
}
},
90
'plugins_loaded',
function () {
$boxzilla = boxzilla();

// load default filters
require __DIR__ . '/src/default-filters.php';
require __DIR__ . '/src/default-actions.php';

if (defined('DOING_AJAX') && DOING_AJAX) {
$boxzilla['filter.autocomplete']->init();
$boxzilla['admin.menu']->init();
} elseif (defined('DOING_CRON') && DOING_CRON) {
$boxzilla['license_poller']->init();
} elseif (is_admin()) {
$boxzilla['admin']->init();
$boxzilla['admin.menu']->init();
} else {
add_action(
'template_redirect',
function () use ($boxzilla) {
$boxzilla['box_loader']->init();
}
);
}

// license manager
if (is_admin() || ( defined('DOING_CRON') && DOING_CRON ) || ( defined('WP_CLI') && WP_CLI )) {
$boxzilla['license_manager']->init();

if (count($boxzilla->plugins) > 0) {
$boxzilla['update_manager']->init();
}
}
},
90
);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -21,7 +21,8 @@
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "^10.5.40"
"phpunit/phpunit": "^10.5.40",
"squizlabs/php_codesniffer": "^3.11"
},
"scripts": {
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -print0 | xargs -0 -n1 php -l"
13 changes: 13 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<ruleset name="rules">
<description>rules</description>
<arg name="colors"/>
<file>src/</file>
<file>boxzilla.php</file>
<exclude-pattern>*\.(html|css|js)</exclude-pattern>
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>
<rule ref="PSR12">
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>
</ruleset>
Loading

0 comments on commit 13532b6

Please sign in to comment.