Passed
Push — main ( aaef5c...e4c121 )
by TARIQ
71:39
created
packages/action-scheduler/classes/actions/ActionScheduler_Action.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 	protected $schedule = NULL;
11 11
 	protected $group = '';
12 12
 
13
-	public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '' ) {
14
-		$schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule;
13
+	public function __construct($hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '') {
14
+		$schedule = empty($schedule) ? new ActionScheduler_NullSchedule() : $schedule;
15 15
 		$this->set_hook($hook);
16 16
 		$this->set_schedule($schedule);
17 17
 		$this->set_args($args);
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 	}
20 20
 
21 21
 	public function execute() {
22
-		return do_action_ref_array( $this->get_hook(), array_values( $this->get_args() ) );
22
+		return do_action_ref_array($this->get_hook(), array_values($this->get_args()));
23 23
 	}
24 24
 
25 25
 	/**
26 26
 	 * @param string $hook
27 27
 	 */
28
-	protected function set_hook( $hook ) {
28
+	protected function set_hook($hook) {
29 29
 		$this->hook = $hook;
30 30
 	}
31 31
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		return $this->hook;
34 34
 	}
35 35
 
36
-	protected function set_schedule( ActionScheduler_Schedule $schedule ) {
36
+	protected function set_schedule(ActionScheduler_Schedule $schedule) {
37 37
 		$this->schedule = $schedule;
38 38
 	}
39 39
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		return $this->schedule;
45 45
 	}
46 46
 
47
-	protected function set_args( array $args ) {
47
+	protected function set_args(array $args) {
48 48
 		$this->args = $args;
49 49
 	}
50 50
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @param string $group
57 57
 	 */
58
-	protected function set_group( $group ) {
58
+	protected function set_group($group) {
59 59
 		$this->group = $group;
60 60
 	}
61 61
 
Please login to merge, or discard this patch.
packages/action-scheduler/classes/actions/ActionScheduler_NullAction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
  */
6 6
 class ActionScheduler_NullAction extends ActionScheduler_Action {
7 7
 
8
-	public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = NULL ) {
9
-		$this->set_schedule( new ActionScheduler_NullSchedule() );
8
+	public function __construct($hook = '', array $args = array(), ActionScheduler_Schedule $schedule = NULL) {
9
+		$this->set_schedule(new ActionScheduler_NullSchedule());
10 10
 	}
11 11
 
12 12
 	public function execute() {
Please login to merge, or discard this patch.
action-scheduler/classes/actions/ActionScheduler_CanceledAction.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@
 block discarded – undo
14 14
 	 * @param ActionScheduler_Schedule $schedule
15 15
 	 * @param string $group
16 16
 	 */
17
-	public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
18
-		parent::__construct( $hook, $args, $schedule, $group );
19
-		if ( is_null( $schedule ) ) {
20
-			$this->set_schedule( new ActionScheduler_NullSchedule() );
17
+	public function __construct($hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '') {
18
+		parent::__construct($hook, $args, $schedule, $group);
19
+		if (is_null($schedule)) {
20
+			$this->set_schedule(new ActionScheduler_NullSchedule());
21 21
 		}
22 22
 	}
23 23
 }
Please login to merge, or discard this patch.
packages/action-scheduler/classes/ActionScheduler_ActionClaim.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 	private $id = '';
8 8
 	private $action_ids = array();
9 9
 
10
-	public function __construct( $id, array $action_ids ) {
10
+	public function __construct($id, array $action_ids) {
11 11
 		$this->id = $id;
12 12
 		$this->action_ids = $action_ids;
13 13
 	}
Please login to merge, or discard this patch.
woocommerce/packages/action-scheduler/classes/ActionScheduler_Versions.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 
12 12
 	private $versions = array();
13 13
 
14
-	public function register( $version_string, $initialization_callback ) {
15
-		if ( isset($this->versions[$version_string]) ) {
14
+	public function register($version_string, $initialization_callback) {
15
+		if (isset($this->versions[$version_string])) {
16 16
 			return FALSE;
17 17
 		}
18 18
 		$this->versions[$version_string] = $initialization_callback;
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 
26 26
 	public function latest_version() {
27 27
 		$keys = array_keys($this->versions);
28
-		if ( empty($keys) ) {
28
+		if (empty($keys)) {
29 29
 			return false;
30 30
 		}
31
-		uasort( $keys, 'version_compare' );
31
+		uasort($keys, 'version_compare');
32 32
 		return end($keys);
33 33
 	}
34 34
 
35 35
 	public function latest_version_callback() {
36 36
 		$latest = $this->latest_version();
37
-		if ( empty($latest) || !isset($this->versions[$latest]) ) {
37
+		if (empty($latest) || !isset($this->versions[$latest])) {
38 38
 			return '__return_null';
39 39
 		}
40 40
 		return $this->versions[$latest];
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @codeCoverageIgnore
46 46
 	 */
47 47
 	public static function instance() {
48
-		if ( empty(self::$instance) ) {
48
+		if (empty(self::$instance)) {
49 49
 			self::$instance = new self();
50 50
 		}
51 51
 		return self::$instance;
Please login to merge, or discard this patch.
packages/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 	private $store = NULL;
11 11
 	private $action_id = 0;
12 12
 
13
-	public function __construct( ActionScheduler_Store $store ) {
13
+	public function __construct(ActionScheduler_Store $store) {
14 14
 		$this->store = $store;
15 15
 	}
16 16
 
17
-	public function attach( ActionScheduler_ActionClaim $claim ) {
17
+	public function attach(ActionScheduler_ActionClaim $claim) {
18 18
 		$this->claim = $claim;
19
-		add_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
20
-		add_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0, 1 );
21
-		add_action( 'action_scheduler_after_execute',  array( $this, 'untrack_action' ), 0, 0 );
22
-		add_action( 'action_scheduler_execution_ignored',  array( $this, 'untrack_action' ), 0, 0 );
23
-		add_action( 'action_scheduler_failed_execution',  array( $this, 'untrack_action' ), 0, 0 );
19
+		add_action('shutdown', array($this, 'handle_unexpected_shutdown'));
20
+		add_action('action_scheduler_before_execute', array($this, 'track_current_action'), 0, 1);
21
+		add_action('action_scheduler_after_execute', array($this, 'untrack_action'), 0, 0);
22
+		add_action('action_scheduler_execution_ignored', array($this, 'untrack_action'), 0, 0);
23
+		add_action('action_scheduler_failed_execution', array($this, 'untrack_action'), 0, 0);
24 24
 	}
25 25
 
26 26
 	public function detach() {
27 27
 		$this->claim = NULL;
28 28
 		$this->untrack_action();
29
-		remove_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
30
-		remove_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0 );
31
-		remove_action( 'action_scheduler_after_execute',  array( $this, 'untrack_action' ), 0 );
32
-		remove_action( 'action_scheduler_execution_ignored',  array( $this, 'untrack_action' ), 0 );
33
-		remove_action( 'action_scheduler_failed_execution',  array( $this, 'untrack_action' ), 0 );
29
+		remove_action('shutdown', array($this, 'handle_unexpected_shutdown'));
30
+		remove_action('action_scheduler_before_execute', array($this, 'track_current_action'), 0);
31
+		remove_action('action_scheduler_after_execute', array($this, 'untrack_action'), 0);
32
+		remove_action('action_scheduler_execution_ignored', array($this, 'untrack_action'), 0);
33
+		remove_action('action_scheduler_failed_execution', array($this, 'untrack_action'), 0);
34 34
 	}
35 35
 
36
-	public function track_current_action( $action_id ) {
36
+	public function track_current_action($action_id) {
37 37
 		$this->action_id = $action_id;
38 38
 	}
39 39
 
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 	}
43 43
 
44 44
 	public function handle_unexpected_shutdown() {
45
-		if ( $error = error_get_last() ) {
46
-			if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) {
47
-				if ( !empty($this->action_id) ) {
48
-					$this->store->mark_failure( $this->action_id );
49
-					do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error );
45
+		if ($error = error_get_last()) {
46
+			if (in_array($error['type'], array(E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) {
47
+				if (!empty($this->action_id)) {
48
+					$this->store->mark_failure($this->action_id);
49
+					do_action('action_scheduler_unexpected_shutdown', $this->action_id, $error);
50 50
 				}
51 51
 			}
52
-			$this->store->release_claim( $this->claim );
52
+			$this->store->release_claim($this->claim);
53 53
 		}
54 54
 	}
55 55
 }
Please login to merge, or discard this patch.
packages/action-scheduler/classes/schema/ActionScheduler_StoreSchema.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	 * Performs additional setup work required to support this schema.
31 31
 	 */
32 32
 	public function init() {
33
-		add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_5_0' ), 10, 2 );
33
+		add_action('action_scheduler_before_schema_update', array($this, 'update_schema_5_0'), 10, 2);
34 34
 	}
35 35
 
36
-	protected function get_table_definition( $table ) {
36
+	protected function get_table_definition($table) {
37 37
 		global $wpdb;
38 38
 		$table_name       = $wpdb->$table;
39 39
 		$charset_collate  = $wpdb->get_charset_collate();
40 40
 		$max_index_length = 191; // @see wp_get_db_schema()
41 41
 		$default_date     = self::DEFAULT_DATE;
42
-		switch ( $table ) {
42
+		switch ($table) {
43 43
 
44 44
 			case self::ACTIONS_TABLE:
45 45
 
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 	 * @param string $table Name of table being updated.
103 103
 	 * @param string $db_version The existing schema version of the table.
104 104
 	 */
105
-	public function update_schema_5_0( $table, $db_version ) {
105
+	public function update_schema_5_0($table, $db_version) {
106 106
 		global $wpdb;
107 107
 
108
-		if ( 'actionscheduler_actions' !== $table || version_compare( $db_version, '5', '>=' ) ) {
108
+		if ('actionscheduler_actions' !== $table || version_compare($db_version, '5', '>=')) {
109 109
 			return;
110 110
 		}
111 111
 
112 112
 		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
113 113
 		$table_name   = $wpdb->prefix . 'actionscheduler_actions';
114
-		$table_list   = $wpdb->get_col( "SHOW TABLES LIKE '${table_name}'" );
114
+		$table_list   = $wpdb->get_col("SHOW TABLES LIKE '${table_name}'");
115 115
 		$default_date = self::DEFAULT_DATE;
116 116
 
117
-		if ( ! empty( $table_list ) ) {
117
+		if (!empty($table_list)) {
118 118
 			$query = "
119 119
 				ALTER TABLE ${table_name}
120 120
 				MODIFY COLUMN scheduled_date_gmt datetime NULL default '${default_date}',
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				MODIFY COLUMN last_attempt_gmt datetime NULL default '${default_date}',
123 123
 				MODIFY COLUMN last_attempt_local datetime NULL default '${default_date}'
124 124
 		";
125
-			$wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
125
+			$wpdb->query($query); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
126 126
 		}
127 127
 		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
128 128
 	}
Please login to merge, or discard this patch.
packages/action-scheduler/classes/schema/ActionScheduler_LoggerSchema.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 	 * Performs additional setup work required to support this schema.
26 26
 	 */
27 27
 	public function init() {
28
-		add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_3_0' ), 10, 2 );
28
+		add_action('action_scheduler_before_schema_update', array($this, 'update_schema_3_0'), 10, 2);
29 29
 	}
30 30
 
31
-	protected function get_table_definition( $table ) {
31
+	protected function get_table_definition($table) {
32 32
 		global $wpdb;
33 33
 		$table_name       = $wpdb->$table;
34 34
 		$charset_collate  = $wpdb->get_charset_collate();
35
-		switch ( $table ) {
35
+		switch ($table) {
36 36
 
37 37
 			case self::LOG_TABLE:
38 38
 
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
 	 * @param string $table Name of table being updated.
66 66
 	 * @param string $db_version The existing schema version of the table.
67 67
 	 */
68
-	public function update_schema_3_0( $table, $db_version ) {
68
+	public function update_schema_3_0($table, $db_version) {
69 69
 		global $wpdb;
70 70
 
71
-		if ( 'actionscheduler_logs' !== $table || version_compare( $db_version, '3', '>=' ) ) {
71
+		if ('actionscheduler_logs' !== $table || version_compare($db_version, '3', '>=')) {
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
76 76
 		$table_name   = $wpdb->prefix . 'actionscheduler_logs';
77
-		$table_list   = $wpdb->get_col( "SHOW TABLES LIKE '${table_name}'" );
77
+		$table_list   = $wpdb->get_col("SHOW TABLES LIKE '${table_name}'");
78 78
 		$default_date = ActionScheduler_StoreSchema::DEFAULT_DATE;
79 79
 
80
-		if ( ! empty( $table_list ) ) {
80
+		if (!empty($table_list)) {
81 81
 			$query = "
82 82
 				ALTER TABLE ${table_name}
83 83
 				MODIFY COLUMN log_date_gmt datetime NULL default '${default_date}',
84 84
 				MODIFY COLUMN log_date_local datetime NULL default '${default_date}'
85 85
 			";
86
-			$wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
86
+			$wpdb->query($query); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
87 87
 		}
88 88
 		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
89 89
 	}
Please login to merge, or discard this patch.
packages/action-scheduler/classes/ActionScheduler_Compatibility.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,24 +16,24 @@  discard block
 block discarded – undo
16 16
 	 * @param string $value A (PHP ini) byte value, either shorthand or ordinary.
17 17
 	 * @return int An integer byte value.
18 18
 	 */
19
-	public static function convert_hr_to_bytes( $value ) {
20
-		if ( function_exists( 'wp_convert_hr_to_bytes' ) ) {
21
-			return wp_convert_hr_to_bytes( $value );
19
+	public static function convert_hr_to_bytes($value) {
20
+		if (function_exists('wp_convert_hr_to_bytes')) {
21
+			return wp_convert_hr_to_bytes($value);
22 22
 		}
23 23
 
24
-		$value = strtolower( trim( $value ) );
24
+		$value = strtolower(trim($value));
25 25
 		$bytes = (int) $value;
26 26
 
27
-		if ( false !== strpos( $value, 'g' ) ) {
27
+		if (false !== strpos($value, 'g')) {
28 28
 			$bytes *= GB_IN_BYTES;
29
-		} elseif ( false !== strpos( $value, 'm' ) ) {
29
+		} elseif (false !== strpos($value, 'm')) {
30 30
 			$bytes *= MB_IN_BYTES;
31
-		} elseif ( false !== strpos( $value, 'k' ) ) {
31
+		} elseif (false !== strpos($value, 'k')) {
32 32
 			$bytes *= KB_IN_BYTES;
33 33
 		}
34 34
 
35 35
 		// Deal with large (float) values which run into the maximum integer size.
36
-		return min( $bytes, PHP_INT_MAX );
36
+		return min($bytes, PHP_INT_MAX);
37 37
 	}
38 38
 
39 39
 	/**
@@ -46,30 +46,30 @@  discard block
 block discarded – undo
46 46
 	 * @return bool|int|string The limit that was set or false on failure.
47 47
 	 */
48 48
 	public static function raise_memory_limit() {
49
-		if ( function_exists( 'wp_raise_memory_limit' ) ) {
50
-			return wp_raise_memory_limit( 'admin' );
49
+		if (function_exists('wp_raise_memory_limit')) {
50
+			return wp_raise_memory_limit('admin');
51 51
 		}
52 52
 
53
-		$current_limit     = @ini_get( 'memory_limit' );
54
-		$current_limit_int = self::convert_hr_to_bytes( $current_limit );
53
+		$current_limit     = @ini_get('memory_limit');
54
+		$current_limit_int = self::convert_hr_to_bytes($current_limit);
55 55
 
56 56
 		if ( -1 === $current_limit_int ) {
57 57
 			return false;
58 58
 		}
59 59
 
60 60
 		$wp_max_limit       = WP_MAX_MEMORY_LIMIT;
61
-		$wp_max_limit_int   = self::convert_hr_to_bytes( $wp_max_limit );
62
-		$filtered_limit     = apply_filters( 'admin_memory_limit', $wp_max_limit );
63
-		$filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit );
61
+		$wp_max_limit_int   = self::convert_hr_to_bytes($wp_max_limit);
62
+		$filtered_limit     = apply_filters('admin_memory_limit', $wp_max_limit);
63
+		$filtered_limit_int = self::convert_hr_to_bytes($filtered_limit);
64 64
 
65
-		if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
66
-			if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {
65
+		if ( -1 === $filtered_limit_int || ($filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int) ) {
66
+			if (false !== @ini_set('memory_limit', $filtered_limit)) {
67 67
 				return $filtered_limit;
68 68
 			} else {
69 69
 				return false;
70 70
 			}
71 71
 		} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
72
-			if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {
72
+			if (false !== @ini_set('memory_limit', $wp_max_limit)) {
73 73
 				return $wp_max_limit;
74 74
 			} else {
75 75
 				return false;
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param int $limit The time limit in seconds.
87 87
 	 */
88
-	public static function raise_time_limit( $limit = 0 ) {
88
+	public static function raise_time_limit($limit = 0) {
89 89
 		$limit = (int) $limit;
90
-		$max_execution_time = (int) ini_get( 'max_execution_time' );
90
+		$max_execution_time = (int) ini_get('max_execution_time');
91 91
 
92 92
 		/*
93 93
 		 * If the max execution time is already unlimited (zero), or if it exceeds or is equal to the proposed
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 		 */
96 96
 		if (
97 97
 			0 === $max_execution_time
98
-			|| ( $max_execution_time >= $limit && $limit !== 0 )
98
+			|| ($max_execution_time >= $limit && $limit !== 0)
99 99
 		) {
100 100
 			return;
101 101
 		}
102 102
 
103
-		if ( function_exists( 'wc_set_time_limit' ) ) {
104
-			wc_set_time_limit( $limit );
105
-		} elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
106
-			@set_time_limit( $limit ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
103
+		if (function_exists('wc_set_time_limit')) {
104
+			wc_set_time_limit($limit);
105
+		} elseif (function_exists('set_time_limit') && false === strpos(ini_get('disable_functions'), 'set_time_limit') && !ini_get('safe_mode')) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
106
+			@set_time_limit($limit); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
107 107
 		}
108 108
 	}
109 109
 }
Please login to merge, or discard this patch.