Skip to content

Commit

Permalink
Merge pull request #157 from soup-bowl/soup-bowl/wpcs-lint-2024-2
Browse files Browse the repository at this point in the history
WordPress Coding Standards Linting
  • Loading branch information
soup-bowl authored Jan 23, 2024
2 parents 80c2040 + 1c08967 commit 947548f
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion assets/smtp-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { __ } = wp.i18n;
function wpss_loadin() {
if ( null !== document.getElementById( 'wpss-conf' ) ) {
wpss_load_quicksettings( wpss_qc_settings );
document.getElementById( 'wpss-quickset' ).onchange = function( stuff ) {
document.getElementById( 'wpss-quickset' ).onchange = function ( stuff ) {
wpss_input_selection( wpss_qc_settings, stuff.target.value );
};
}
Expand Down
7 changes: 6 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<exclude-pattern>wp-simple-smtp.php</exclude-pattern>
</rule>

<rule ref="Generic.Arrays.DisallowShortArraySyntax">
<rule ref="Universal.Arrays.DisallowShortArraySyntax">
<exclude-pattern>*/*</exclude-pattern>
</rule>

Expand All @@ -37,5 +37,10 @@
<rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
<exclude-pattern>tests/log/class-logservice-test.php</exclude-pattern>
</rule>

<!-- Some mocks will refer to variables that it will discard. -->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!-- ! Test exclusions. -->
</ruleset>
16 changes: 6 additions & 10 deletions src/class-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,21 @@ public function get( $name, $blank_obj_on_empty = true, $ms_only = false ) {
'value' => $this->maybe_decrypt( $options, $name ),
'source' => 'CONFIG',
];
} else {
if ( $blank_obj_on_empty ) {
} elseif ( $blank_obj_on_empty ) {
return (object) [
'value' => '',
'source' => 'CONFIG',
];
} else {
return null;
}
} else {
return null;
}
} else {
if ( $blank_obj_on_empty ) {
} elseif ( $blank_obj_on_empty ) {
return (object) [
'value' => '',
'source' => 'MULTISITE',
];
} else {
return null;
}
} else {
return null;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/log/class-logservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,4 @@ private function wp_to_obj( $post ) {

return $log;
}

}
4 changes: 2 additions & 2 deletions src/mail/class-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct() {
if ( ! empty( $from->value ) ) {
add_filter(
'wp_mail_from',
function( $email ) use ( $from ) {
function ( $email ) use ( $from ) {
return $from->value;
}
);
Expand All @@ -53,7 +53,7 @@ function( $email ) use ( $from ) {
if ( ! empty( $from_name->value ) ) {
add_filter(
'wp_mail_from_name',
function( $email ) use ( $from_name ) {
function ( $email ) use ( $from_name ) {
return $from_name->value;
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/settings/class-multisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function () {
$this->generate_checkbox_area(
'adt',
__( 'Options', 'simple-smtp' ),
function() {
function () {
$this->generate_checkbox( 'disable', __( 'Disable email services', 'simple-smtp' ), __( 'When marked, all multisite email services will be disabled.', 'simple-smtp' ) );
$this->generate_checkbox( 'log', __( 'Log all sent emails to the database', 'simple-smtp' ), __( 'Works with the WordPress privacy features.', 'simple-smtp' ) );
$this->generate_checkbox( 'noverifyssl', __( 'Disable SSL Verification (advanced)', 'simple-smtp' ), __( 'Do not disable this unless you know what you\'re doing.', 'simple-smtp' ) );
Expand Down
2 changes: 1 addition & 1 deletion src/settings/class-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function hooks() {
if ( ! empty( $log_status ) && true === filter_var( $log_status->value, FILTER_VALIDATE_BOOLEAN ) ) {
add_filter(
'wp_privacy_personal_data_erasers',
function( $erasers ) {
function ( $erasers ) {
$erasers['wp-simple-smtp'] = array(
'eraser_friendly_name' => __( 'Remove user from SMTP log', 'simple-smtp' ),
'callback' => [ &$this, 'remove_data' ],
Expand Down
2 changes: 1 addition & 1 deletion src/settings/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function generate_checkbox_area( $name, $name_pretty, $callback ) {
add_settings_field(
'wpssmtp_smtp_' . $name,
$name_pretty,
function() use ( &$callback ) {
function () use ( &$callback ) {
?>
<fieldset>
<?php call_user_func( $callback ); ?>
Expand Down
3 changes: 1 addition & 2 deletions src/settings/class-singular.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public function options_page() {
} else {
$this->render_settings();
}

}

/**
Expand Down Expand Up @@ -166,7 +165,7 @@ function () {
$this->generate_checkbox_area(
'adt',
__( 'Options', 'simple-smtp' ),
function() {
function () {
$this->generate_checkbox( 'disable', __( 'Disable email services', 'simple-smtp' ), __( 'When marked, no emails will be sent from this site.', 'simple-smtp' ) );
$this->generate_checkbox( 'log', __( 'Log all sent emails to the database', 'simple-smtp' ), __( 'Works with the WordPress privacy features.', 'simple-smtp' ) );
$this->generate_checkbox( 'noverifyssl', __( 'Disable SSL Verification (advanced)', 'simple-smtp' ), __( 'Do not disable this unless you know what you\'re doing.', 'simple-smtp' ) );
Expand Down
6 changes: 3 additions & 3 deletions tests/class-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1
* Mocks the WordPress get_option function.
* See https://developer.wordpress.org/reference/functions/get_option/ for more information.
*
* @param string $option Key name.
* @param mixed $default Default return.
* @param string $option Key name.
* @param mixed $default_return Default return.
* @return mixed
*/
function get_option( $option, $default = false ) {
function get_option( $option, $default_return = false ) {
global $sbss_temp_store;

$env_loc = __DIR__ . '/../.env';
Expand Down
2 changes: 1 addition & 1 deletion tests/class-options-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OptionsTest extends TestCase {
/**
* Constructor.
*/
public function setUp():void {
public function setUp(): void {
if ( ! defined( 'SECURE_AUTH_KEY' ) ) {
define( 'SECURE_AUTH_KEY', 's7r0237r897d89s69r83289' );
}
Expand Down
2 changes: 1 addition & 1 deletion tests/log/class-logservice-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class LogServiceTest extends TestCase {
/**
* Per-test constructor.
*/
public function setUp():void {
public function setUp(): void {
$this->log_service = new LogService();

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/mail/class-mail-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MailTest extends TestCase {
/**
* Constructor.
*/
public function setUp():void {
public function setUp(): void {
$this->mail = new Mail();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/settings/class-settings-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SettingsTest extends TestCase {
/**
* Constructor.
*/
public function setUp():void {
public function setUp(): void {
$this->settings = new Settings();
$this->multisite_settings = new SettingsMultisite();
$this->options = new Options();
Expand Down
8 changes: 4 additions & 4 deletions wp-simple-smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
if ( ! empty( $disabled ) && true === filter_var( $disabled->value, FILTER_VALIDATE_BOOLEAN ) ) {
add_action(
'plugins_loaded',
function() {
function () {
global $phpmailer;
$phpmailer = new MailDisable();
}
Expand All @@ -64,14 +64,14 @@ function() {

add_action(
'wpss_clear_resent',
function() {
function () {
delete_option( 'wpss_resent' );
}
);

add_action(
'wpss_clear_logs',
function() {
function () {
$is_disabled = apply_filters( 'simple_smtp_disable_log_prune', false );
// 2629800 = 1 Month.
if ( ! $is_disabled ) {
Expand Down Expand Up @@ -136,7 +136,7 @@ function wpsmtp_deactivation() {
*/
add_action(
'init',
function() {
function () {
( new LogService() )->register_log_storage();
}
);
Expand Down

0 comments on commit 947548f

Please sign in to comment.