Documentation

WPDBTrait

Helper utilities for sniffs which examine WPDB method calls.

Tags
since
3.0.0

The method in this trait was previously contained in the WordPressCS\WordPress\Sniff class and has been moved here.

Table of Contents

Methods

is_wpdb_method_call()  : bool
Checks whether this is a call to a $wpdb method that we want to sniff.

Methods

is_wpdb_method_call()

Checks whether this is a call to a $wpdb method that we want to sniff.

protected final is_wpdb_method_call(File $phpcsFile, int $stackPtr, array<string|int, mixed> $target_methods) : bool

If available in the class using this trait, the $methodPtr, $i and $end properties are automatically set to correspond to the start and end of the method call. The $i property is also set if this is not a method call but rather the use of a $wpdb property.

Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The index of the $wpdb variable.

$target_methods : array<string|int, mixed>

Array of methods. Key(s) should be method name in lowercase.

Tags
since
0.8.0
since
0.9.0

The return value is now always boolean. The $end and $i member vars are automatically updated.

since
0.14.0

Moved this method from the PreparedSQL sniff to the base WP sniff.

since
3.0.0
  • Moved from the Sniff class to this dedicated Trait. - The $phpcsFile parameter was added.

}

Return values
bool

Whether this is a $wpdb method call.


        
On this page

Search results