Commit 2ff3fef2 authored by Erick Hitter's avatar Erick Hitter
Browse files

PHPCS fixes

parent c7a9ecbe
<?php <?php
/**
* Common functions, often wrappers for various classes
*
* @package a8c_Cron_Control
*/
namespace Automattic\WP\Cron_Control; namespace Automattic\WP\Cron_Control;
/** /**
* Check if an event is an internal one that the plugin will always run * Check if an event is an internal one that the plugin will always run
*
* @param string $action Action name.
* @return bool
*/ */
function is_internal_event( $action ) { function is_internal_event( $action ) {
return Internal_Events::instance()->is_internal_event( $action ); return Internal_Events::instance()->is_internal_event( $action );
...@@ -15,19 +23,19 @@ function is_internal_event( $action ) { ...@@ -15,19 +23,19 @@ function is_internal_event( $action ) {
* @return string|bool * @return string|bool
*/ */
function get_endpoint_type() { function get_endpoint_type() {
// Request won't change, so hold for the duration // Request won't change, so hold for the duration.
static $endpoint_slug = null; static $endpoint_slug = null;
if ( ! is_null( $endpoint_slug ) ) { if ( ! is_null( $endpoint_slug ) ) {
return $endpoint_slug; return $endpoint_slug;
} }
// Determine request URL according to how Core does // Determine request URL according to how Core does.
$request = parse_request(); $request = parse_request();
// Search by our URL "prefix" // Search by our URL "prefix".
$namespace = sprintf( '%s/%s', rest_get_url_prefix(), REST_API::API_NAMESPACE ); $namespace = sprintf( '%s/%s', rest_get_url_prefix(), REST_API::API_NAMESPACE );
// Check if any parts of the parse request are in our namespace // Check if any parts of the parse request are in our namespace.
$endpoint_slug = false; $endpoint_slug = false;
foreach ( $request as $req ) { foreach ( $request as $req ) {
...@@ -44,8 +52,7 @@ function get_endpoint_type() { ...@@ -44,8 +52,7 @@ function get_endpoint_type() {
/** /**
* Check if the current request is to one of the plugin's REST endpoints * Check if the current request is to one of the plugin's REST endpoints
* *
* @param string $type Endpoint Constant from REST_API class to compare against * @param string $type Endpoint Constant from REST_API class to compare against.
*
* @return bool * @return bool
*/ */
function is_rest_endpoint_request( $type ) { function is_rest_endpoint_request( $type ) {
...@@ -55,10 +62,10 @@ function is_rest_endpoint_request( $type ) { ...@@ -55,10 +62,10 @@ function is_rest_endpoint_request( $type ) {
/** /**
* Schedule an event directly, bypassing the plugin's filtering to capture Core's scheduling functions * Schedule an event directly, bypassing the plugin's filtering to capture Core's scheduling functions
* *
* @param int $timestamp Time event should run * @param int $timestamp Time event should run.
* @param string $action Hook to fire * @param string $action Hook to fire.
* @param array $args Array of arguments, such as recurrence and parameters to pass to hook callback * @param array $args Array of arguments, such as recurrence and parameters to pass to hook callback.
* @param int|null $job_id Optional. Job ID to update * @param int|null $job_id Optional. Job ID to update.
*/ */
function schedule_event( $timestamp, $action, $args, $job_id = null ) { function schedule_event( $timestamp, $action, $args, $job_id = null ) {
Events_Store::instance()->create_or_update_job( $timestamp, $action, $args, $job_id ); Events_Store::instance()->create_or_update_job( $timestamp, $action, $args, $job_id );
...@@ -67,11 +74,10 @@ function schedule_event( $timestamp, $action, $args, $job_id = null ) { ...@@ -67,11 +74,10 @@ function schedule_event( $timestamp, $action, $args, $job_id = null ) {
/** /**
* Execute a specific event * Execute a specific event
* *
* @param int $timestamp Unix timestamp * @param int $timestamp Unix timestamp.
* @param string $action_hashed md5 hash of the action used when the event is registered * @param string $action_hashed md5 hash of the action used when the event is registered.
* @param string $instance md5 hash of the event's arguments array, which Core uses to index the `cron` option * @param string $instance md5 hash of the event's arguments array, which Core uses to index the `cron` option.
* @param bool $force Run event regardless of timestamp or lock status? eg, when executing jobs via wp-cli * @param bool $force Run event regardless of timestamp or lock status? eg, when executing jobs via wp-cli.
*
* @return array|\WP_Error * @return array|\WP_Error
*/ */
function run_event( $timestamp, $action_hashed, $instance, $force = false ) { function run_event( $timestamp, $action_hashed, $instance, $force = false ) {
...@@ -81,9 +87,9 @@ function run_event( $timestamp, $action_hashed, $instance, $force = false ) { ...@@ -81,9 +87,9 @@ function run_event( $timestamp, $action_hashed, $instance, $force = false ) {
/** /**
* Delete an event entry directly, bypassing the plugin's filtering to capture same * Delete an event entry directly, bypassing the plugin's filtering to capture same
* *
* @param int $timestamp Time event should run * @param int $timestamp Time event should run.
* @param string $action Hook to fire * @param string $action Hook to fire.
* @param string $instance Hashed version of event's arguments * @param string $instance Hashed version of event's arguments.
*/ */
function delete_event( $timestamp, $action, $instance ) { function delete_event( $timestamp, $action, $instance ) {
Events_Store::instance()->mark_job_completed( $timestamp, $action, $instance ); Events_Store::instance()->mark_job_completed( $timestamp, $action, $instance );
...@@ -92,8 +98,8 @@ function delete_event( $timestamp, $action, $instance ) { ...@@ -92,8 +98,8 @@ function delete_event( $timestamp, $action, $instance ) {
/** /**
* Delete an event by its ID * Delete an event by its ID
* *
* @param int $id Event ID * @param int $id Event ID.
* $param bool $flush_cache Flush internal cacehs * @param bool $flush_cache Flush internal caches.
* @return bool * @return bool
*/ */
function delete_event_by_id( $id, $flush_cache = false ) { function delete_event_by_id( $id, $flush_cache = false ) {
...@@ -103,7 +109,7 @@ function delete_event_by_id( $id, $flush_cache = false ) { ...@@ -103,7 +109,7 @@ function delete_event_by_id( $id, $flush_cache = false ) {
/** /**
* Retrieve jobs given a set of parameters * Retrieve jobs given a set of parameters
* *
* @param array $args * @param array $args Event arguments to filter by.
* @return array * @return array
*/ */
function get_events( $args ) { function get_events( $args ) {
...@@ -113,7 +119,7 @@ function get_events( $args ) { ...@@ -113,7 +119,7 @@ function get_events( $args ) {
/** /**
* Retrieve a single event by ID, or by a combination of its timestamp, instance identifier, and either action or the action's hashed representation * Retrieve a single event by ID, or by a combination of its timestamp, instance identifier, and either action or the action's hashed representation
* *
* @param array $attributes Array of event attributes to query by * @param array $attributes Array of event attributes to query by.
* @return object|false * @return object|false
*/ */
function get_event_by_attributes( $attributes ) { function get_event_by_attributes( $attributes ) {
...@@ -123,7 +129,7 @@ function get_event_by_attributes( $attributes ) { ...@@ -123,7 +129,7 @@ function get_event_by_attributes( $attributes ) {
/** /**
* Retrieve a single event by its ID * Retrieve a single event by its ID
* *
* @param int $jid Job ID * @param int $jid Job ID.
* @return object|false * @return object|false
*/ */
function get_event_by_id( $jid ) { function get_event_by_id( $jid ) {
...@@ -133,7 +139,7 @@ function get_event_by_id( $jid ) { ...@@ -133,7 +139,7 @@ function get_event_by_id( $jid ) {
/** /**
* Count events with a given status * Count events with a given status
* *
* @param string $status Status to count * @param string $status Status to count.
* @return int|false * @return int|false
*/ */
function count_events_by_status( $status ) { function count_events_by_status( $status ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment