Documentation

CronIntervalSniff extends Sniff

FinalYes

Flag cron schedules less than 15 minutes.

Tags
link
https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/#cron-schedules-less-than-15-minutes-or-expensive-events
since
0.3.0
since
0.11.0
  • Extends the WordPressCS native Sniff class.
  • Now deals correctly with WP time constants.
since
0.13.0

Class name changed: this class is now namespaced.

since
0.14.0

The minimum cron interval tested against is now configurable.

since
1.0.0

This sniff has been moved from the VIP category to the WP category.

Table of Contents

Properties

$min_interval  : int
Minimum allowed cron interval in seconds.
$phpcsFile  : File
The current file being sniffed.
$tokens  : array<string|int, mixed>
The list of tokens in the current file being sniffed.
$valid_functions  : array<string|int, mixed>
Function within which the hook should be found.
$wp_time_constants  : array<string|int, mixed>
Known WP Time constant names and their value.

Methods

confused()  : void
Add warning about unclear cron schedule change.
process()  : int|void
Set sniff properties and hand off to child class for processing of the token.
process_token()  : void
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, mixed>
Returns an array of tokens this test wants to listen for.
find_function_by_name()  : int|false
Find a declared function in a file based on the function name.

Properties

$min_interval

Minimum allowed cron interval in seconds.

public int $min_interval = 900

Defaults to 900 (= 15 minutes), which is the requirement for the VIP platform.

Tags
since
0.14.0

$phpcsFile

The current file being sniffed.

protected File $phpcsFile
Tags
since
0.4.0

$tokens

The list of tokens in the current file being sniffed.

protected array<string|int, mixed> $tokens
Tags
since
0.4.0

$valid_functions

Function within which the hook should be found.

protected array<string|int, mixed> $valid_functions = array('add_filter' => true)

$wp_time_constants

Known WP Time constant names and their value.

protected array<string|int, mixed> $wp_time_constants = array('MINUTE_IN_SECONDS' => 60, 'HOUR_IN_SECONDS' => 3600, 'DAY_IN_SECONDS' => 86400, 'WEEK_IN_SECONDS' => 604800, 'MONTH_IN_SECONDS' => 2592000, 'YEAR_IN_SECONDS' => 31536000)
Tags
since
0.11.0

Methods

confused()

Add warning about unclear cron schedule change.

public confused(int $stackPtr) : void
Parameters
$stackPtr : int

The position of the current token in the stack.

process()

Set sniff properties and hand off to child class for processing of the token.

public process(File $phpcsFile, int $stackPtr) : int|void
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of the current token in the stack passed in $tokens.

Tags
since
0.11.0
Return values
int|void

Integer stack pointer to skip forward or void to continue normal file processing.

process_token()

Processes this test, when one of its tokens is encountered.

public process_token(int $stackPtr) : void
Parameters
$stackPtr : int

The position of the current token in the stack.

register()

Returns an array of tokens this test wants to listen for.

public register() : array<string|int, mixed>
Return values
array<string|int, mixed>

find_function_by_name()

Find a declared function in a file based on the function name.

private find_function_by_name(string $functionName) : int|false
Parameters
$functionName : string

The name of the function to find.

Return values
int|false

Integer stack pointer to the function keyword token or false if not found.


        
On this page

Search results