Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS fixes: PSR2, PSR12, PEAR #1089

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion classes/ActionScheduler_AdminView.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated {
public static function instance() {

if ( empty( self::$admin_view ) ) {
$class = apply_filters('action_scheduler_admin_view_class', 'ActionScheduler_AdminView');
$class = apply_filters( 'action_scheduler_admin_view_class', 'ActionScheduler_AdminView' );
self::$admin_view = new $class();
}

Expand Down
2 changes: 1 addition & 1 deletion classes/ActionScheduler_FatalErrorMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function handle_unexpected_shutdown() {

if ( $error ) {
if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) {
if ( !empty($this->action_id) ) {
if ( !empty( $this->action_id ) ) {
$this->store->mark_failure( $this->action_id );
do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error );
}
Expand Down
10 changes: 5 additions & 5 deletions classes/ActionScheduler_ListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ public function display_admin_notices() {
if ( 1 == $notification['success'] ) {
$class = 'updated';
switch ( $notification['row_action_type'] ) {
case 'run' :
case 'run':
/* translators: %s: action HTML */
$action_message_html = sprintf( __( 'Successfully executed action: %s', 'action-scheduler' ), $action_hook_html );
break;
case 'cancel' :
case 'cancel':
/* translators: %s: action HTML */
$action_message_html = sprintf( __( 'Successfully canceled action: %s', 'action-scheduler' ), $action_hook_html );
break;
default :
default:
/* translators: %s: action HTML */
$action_message_html = sprintf( __( 'Successfully processed change for action: %s', 'action-scheduler' ), $action_hook_html );
break;
Expand Down Expand Up @@ -567,10 +567,10 @@ protected function recreate_tables() {
protected function process_row_action( $action_id, $row_action_type ) {
try {
switch ( $row_action_type ) {
case 'run' :
case 'run':
$this->runner->process_action( $action_id, 'Admin List Table' );
break;
case 'cancel' :
case 'cancel':
$this->store->cancel_action( $action_id );
break;
}
Expand Down
4 changes: 2 additions & 2 deletions classes/ActionScheduler_QueueCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function reset_timeouts( $time_limit = 300 ) {
if ( $timeout < 0 ) {
return;
}
$cutoff = as_get_datetime_object($timeout . ' seconds ago');
$cutoff = as_get_datetime_object( $timeout . ' seconds ago' );
$actions_to_reset = $this->store->query_actions( array(
'status' => ActionScheduler_Store::STATUS_PENDING,
'modified' => $cutoff,
Expand Down Expand Up @@ -190,7 +190,7 @@ public function mark_failures( $time_limit = 300 ) {
if ( $timeout < 0 ) {
return;
}
$cutoff = as_get_datetime_object($timeout . ' seconds ago');
$cutoff = as_get_datetime_object( $timeout . ' seconds ago' );
$actions_to_reset = $this->store->query_actions( array(
'status' => ActionScheduler_Store::STATUS_RUNNING,
'modified' => $cutoff,
Expand Down
10 changes: 5 additions & 5 deletions classes/ActionScheduler_QueueRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ActionScheduler_QueueRunner extends ActionScheduler_Abstract_QueueRunner {
* @codeCoverageIgnore
*/
public static function instance() {
if ( empty(self::$runner) ) {
$class = apply_filters('action_scheduler_queue_runner_class', 'ActionScheduler_QueueRunner');
if ( empty( self::$runner ) ) {
$class = apply_filters( 'action_scheduler_queue_runner_class', 'ActionScheduler_QueueRunner' );
self::$runner = new $class();
}
return self::$runner;
Expand Down Expand Up @@ -158,8 +158,8 @@ public function run( $context = 'WP Cron' ) {
* @return int The number of actions processed.
*/
protected function do_batch( $size = 100, $context = '' ) {
$claim = $this->store->stake_claim($size);
$this->monitor->attach($claim);
$claim = $this->store->stake_claim( $size );
$this->monitor->attach( $claim );
$processed_actions = 0;

foreach ( $claim->get_actions() as $action_id ) {
Expand All @@ -174,7 +174,7 @@ protected function do_batch( $size = 100, $context = '' ) {
break;
}
}
$this->store->release_claim($claim);
$this->store->release_claim( $claim );
$this->monitor->detach();
$this->clear_caches();
return $processed_actions;
Expand Down
14 changes: 7 additions & 7 deletions classes/ActionScheduler_Versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ActionScheduler_Versions {
* @param callable $initialization_callback Callback to initialize the version.
*/
public function register( $version_string, $initialization_callback ) {
if ( isset($this->versions[$version_string]) ) {
if ( isset( $this->versions[$version_string] ) ) {
return FALSE;
}
$this->versions[$version_string] = $initialization_callback;
Expand All @@ -37,20 +37,20 @@ public function get_versions() {
* Get latest version registered.
*/
public function latest_version() {
$keys = array_keys($this->versions);
if ( empty($keys) ) {
$keys = array_keys( $this->versions );
if ( empty( $keys ) ) {
return false;
}
uasort( $keys, 'version_compare' );
return end($keys);
return end( $keys );
}

/**
* Get callback for latest registered version.
*/
public function latest_version_callback() {
$latest = $this->latest_version();
if ( empty($latest) || !isset($this->versions[$latest]) ) {
if ( empty( $latest ) || !isset( $this->versions[$latest] ) ) {
return '__return_null';
}
return $this->versions[$latest];
Expand All @@ -61,7 +61,7 @@ public function latest_version_callback() {
* @codeCoverageIgnore
*/
public static function instance() {
if ( empty(self::$instance) ) {
if ( empty( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
Expand All @@ -72,6 +72,6 @@ public static function instance() {
*/
public static function initialize_latest_version() {
$self = self::instance();
call_user_func($self->latest_version_callback());
call_user_func( $self->latest_version_callback() );
}
}
2 changes: 1 addition & 1 deletion classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function run( $args, $assoc_args ) {
$exclude_groups = $this->parse_comma_separated_string( $exclude_groups );

if ( ! empty( $exclude_groups ) ) {
ActionScheduler::store()->set_claim_filter('exclude-groups', $exclude_groups );
ActionScheduler::store()->set_claim_filter( 'exclude-groups', $exclude_groups );
}
}

Expand Down
20 changes: 10 additions & 10 deletions classes/abstracts/ActionScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class ActionScheduler {
* Factory.
*/
public static function factory() {
if ( !isset(self::$factory) ) {
if ( !isset( self::$factory ) ) {
self::$factory = new ActionScheduler_ActionFactory();
}
return self::$factory;
Expand Down Expand Up @@ -67,11 +67,11 @@ public static function admin_view() {
* @return string
*/
public static function plugin_path( $path ) {
$base = dirname(self::$plugin_file);
$base = dirname( self::$plugin_file );
if ( $path ) {
return trailingslashit($base) . $path;
return trailingslashit( $base ) . $path;
} else {
return untrailingslashit($base);
return untrailingslashit( $base );
}
}

Expand All @@ -82,7 +82,7 @@ public static function plugin_path( $path ) {
* @return string
*/
public static function plugin_url( $path ) {
return plugins_url($path, self::$plugin_file);
return plugins_url( $path, self::$plugin_file );
}

/**
Expand Down Expand Up @@ -143,7 +143,7 @@ public static function autoload( $class ) {
}

if ( file_exists( $dir . "{$class}.php" ) ) {
include( $dir . "{$class}.php" );
include $dir . "{$class}.php";
return;
}
}
Expand All @@ -163,7 +163,7 @@ public static function init( $plugin_file ) {
*/
do_action( 'action_scheduler_pre_init' );

require_once( self::plugin_path( 'functions.php' ) );
require_once self::plugin_path( 'functions.php' );
ActionScheduler_DataController::init();

$store = self::store();
Expand Down Expand Up @@ -216,7 +216,7 @@ function () {
}

if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) {
require_once( self::plugin_path( 'deprecated/functions.php' ) );
require_once self::plugin_path( 'deprecated/functions.php' );
}

if ( defined( 'WP_CLI' ) && WP_CLI ) {
Expand Down Expand Up @@ -337,14 +337,14 @@ protected static function is_class_cli( $class ) {
* Clone.
*/
final public function __clone() {
trigger_error('Singleton. No cloning allowed!', E_USER_ERROR);
trigger_error( 'Singleton. No cloning allowed!', E_USER_ERROR );
}

/**
* Wakeup.
*/
final public function __wakeup() {
trigger_error('Singleton. No serialization allowed!', E_USER_ERROR);
trigger_error( 'Singleton. No serialization allowed!', E_USER_ERROR );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/abstracts/ActionScheduler_Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract class ActionScheduler_Logger {
* @return ActionScheduler_Logger
*/
public static function instance() {
if ( empty(self::$logger) ) {
$class = apply_filters('action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger');
if ( empty( self::$logger ) ) {
$class = apply_filters( 'action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger' );
self::$logger = new $class();
}
return self::$logger;
Expand Down
10 changes: 5 additions & 5 deletions classes/abstracts/ActionScheduler_TimezoneHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public static function get_local_timezone( $reset = FALSE ) {
if ( $reset ) {
self::$local_timezone = NULL;
}
if ( !isset(self::$local_timezone) ) {
$tzstring = get_option('timezone_string');
if ( !isset( self::$local_timezone ) ) {
$tzstring = get_option( 'timezone_string' );

if ( empty($tzstring) ) {
$gmt_offset = get_option('gmt_offset');
if ( empty( $tzstring ) ) {
$gmt_offset = get_option( 'gmt_offset' );
if ( $gmt_offset == 0 ) {
$tzstring = 'UTC';
} else {
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function get_local_timezone( $reset = FALSE ) {
}
}

self::$local_timezone = new DateTimeZone($tzstring);
self::$local_timezone = new DateTimeZone( $tzstring );
}
return self::$local_timezone;
}
Expand Down
8 changes: 4 additions & 4 deletions classes/actions/ActionScheduler_Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class ActionScheduler_Action {
*/
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '' ) {
$schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule;
$this->set_hook($hook);
$this->set_schedule($schedule);
$this->set_args($args);
$this->set_group($group);
$this->set_hook( $hook );
$this->set_schedule( $schedule );
$this->set_args( $args );
$this->set_group( $group );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/data-stores/ActionScheduler_DBStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ protected function get_query_actions_sql( array $query, $select_or_count = 'sele
'offset' => 0,
'orderby' => 'date',
'order' => 'ASC',
) );
) );

/** @var \wpdb $wpdb */
global $wpdb;
Expand Down
22 changes: 11 additions & 11 deletions classes/data-stores/ActionScheduler_wpCommentLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
* @return string The log entry ID
*/
public function log( $action_id, $message, DateTime $date = NULL ) {
if ( empty($date) ) {
if ( empty( $date ) ) {
$date = as_get_datetime_object();
} else {
$date = as_get_datetime_object( clone $date );
Expand All @@ -35,18 +35,18 @@ public function log( $action_id, $message, DateTime $date = NULL ) {
*/
protected function create_wp_comment( $action_id, $message, DateTime $date ) {

$comment_date_gmt = $date->format('Y-m-d H:i:s');
$comment_date_gmt = $date->format( 'Y-m-d H:i:s' );
ActionScheduler_TimezoneHelper::set_local_timezone( $date );
$comment_data = array(
'comment_post_ID' => $action_id,
'comment_date' => $date->format('Y-m-d H:i:s'),
'comment_date' => $date->format( 'Y-m-d H:i:s' ),
'comment_date_gmt' => $comment_date_gmt,
'comment_author' => self::AGENT,
'comment_content' => $message,
'comment_agent' => self::AGENT,
'comment_type' => self::TYPE,
);
return wp_insert_comment($comment_data);
return wp_insert_comment( $comment_data );
}

/**
Expand All @@ -58,7 +58,7 @@ protected function create_wp_comment( $action_id, $message, DateTime $date ) {
*/
public function get_entry( $entry_id ) {
$comment = $this->get_comment( $entry_id );
if ( empty($comment) || $comment->comment_type != self::TYPE ) {
if ( empty( $comment ) || $comment->comment_type != self::TYPE ) {
return new ActionScheduler_NullLogEntry();
}

Expand All @@ -76,7 +76,7 @@ public function get_entry( $entry_id ) {
*/
public function get_logs( $action_id ) {
$status = 'all';
if ( get_post_status($action_id) == 'trash' ) {
if ( get_post_status( $action_id ) == 'trash' ) {
$status = 'post-trashed';
}
$comments = get_comments(array(
Expand All @@ -89,7 +89,7 @@ public function get_logs( $action_id ) {
$logs = array();
foreach ( $comments as $c ) {
$entry = $this->get_entry( $c );
if ( !empty($entry) ) {
if ( !empty( $entry ) ) {
$logs[] = $entry;
}
}
Expand All @@ -114,7 +114,7 @@ protected function get_comment( $comment_id ) {
*/
public function filter_comment_queries( $query ) {
foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) {
if ( !empty($query->query_vars[$key]) ) {
if ( !empty( $query->query_vars[$key] ) ) {
return; // don't slow down queries that wouldn't include action_log comments anyway.
}
}
Expand All @@ -131,7 +131,7 @@ public function filter_comment_queries( $query ) {
* @return array
*/
public function filter_comment_query_clauses( $clauses, $query ) {
if ( !empty($query->query_vars['action_log_filter']) ) {
if ( !empty( $query->query_vars['action_log_filter'] ) ) {
$clauses['where'] .= $this->get_where_clause();
}
return $clauses;
Expand Down Expand Up @@ -258,14 +258,14 @@ public function init() {
* Defer comment counting.
*/
public function disable_comment_counting() {
wp_defer_comment_counting(true);
wp_defer_comment_counting( true );
}

/**
* Enable comment counting.
*/
public function enable_comment_counting() {
wp_defer_comment_counting(false);
wp_defer_comment_counting( false );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function post_type_args() {
),
);

$args = apply_filters('action_scheduler_post_type_args', $args);
$args = apply_filters( 'action_scheduler_post_type_args', $args );
return $args;
}
}
Loading
Loading