Documentation

PostsPerPageSniff extends AbstractArrayAssignmentRestrictionsSniff

FinalYes

Flag returning high or infinite posts_per_page.

Tags
link
https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/#no-limit-queries
since
0.3.0
since
0.13.0

Class name changed: this class is now namespaced.

since
0.14.0

Added the posts_per_page property.

since
1.0.0

This sniff has been split into two, with the check for high pagination limit being part of the WP category, and the check for pagination disabling being part of the VIP category.

Table of Contents

Properties

$exclude  : array<string|int, string>
Exclude groups.
$groups  : array<string, array<string|int, mixed>>
Groups of variable data to check against.
$posts_per_page  : int
Posts per page limit to check against.
$excluded_groups  : array<string, bool>
Cache for the excluded groups information.
$groups_cache  : array<string, array<string|int, mixed>>
Cache for the group information.
$phpcsFile  : File
The current file being sniffed.
$tokens  : array<string|int, mixed>
The list of tokens in the current file being sniffed.

Methods

callback()  : bool
Callback to process each confirmed key, to check value.
getGroups()  : array<string|int, mixed>
Groups of variables to restrict.
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.
setup_groups()  : bool
Cache the groups.

Properties

$exclude

Exclude groups.

public array<string|int, string> $exclude = array()

Example: 'foo,bar'

Tags
since
0.3.0
since
1.0.0

This property now expects to be passed an array. Previously a comma-delimited string was expected.

$groups

Groups of variable data to check against.

public static array<string, array<string|int, mixed>> $groups = array()

Don't use this in extended classes, override getGroups() instead. This is only used for Unit tests.

$posts_per_page

Posts per page limit to check against.

public int $posts_per_page = 100
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

Methods

callback()

Callback to process each confirmed key, to check value.

public callback(string $key, mixed $val, int $line, array<string|int, mixed> $group) : bool
Parameters
$key : string

Array index / key.

$val : mixed

Assigned value.

$line : int

Token line.

$group : array<string|int, mixed>

Group definition.

Return values
bool

FALSE if no match, TRUE if matches.

getGroups()

Groups of variables to restrict.

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

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.


        
On this page

Search results