ClassNameCaseSniff
extends AbstractClassRestrictionsSniff
in package
Verify whether references to WP native classes use the proper casing for the class name.
Tags
Table of Contents
Properties
- $exclude : array<string|int, mixed>
- Exclude groups.
- $unittest_groups : array<string|int, mixed>
- Groups of function data to check against.
- $classname : string
- Temporary storage for retrieved class name.
- $excluded_groups : array<string|int, mixed>
- Cache for the excluded groups information.
- $groups : array<string|int, mixed>
- Cache for the group information.
- $phpcsFile : File
- The current file being sniffed.
- $regex_pattern : string
- Regex pattern with placeholder for the class names.
- $tokens : array<string|int, mixed>
- The list of tokens in the current file being sniffed.
- $avif_classes : array<string|int, string>
- List of all AVIF classes included in WP Core.
- $avif_classes_lc : array<string|int, string>
- List of all AVIF classes in lowercase.
- $class_groups : array<string|int, mixed>
- Groups names.
- $getid3_classes : array<string|int, string>
- List of all GetID3 classes included in WP Core.
- $getid3_classes_lc : array<string|int, string>
- List of all GetID3 classes in lowercase.
- $phpmailer_classes : array<string|int, string>
- List of all PHPMailer classes included in WP Core.
- $phpmailer_classes_lc : array<string|int, string>
- List of all PHPMailer classes in lowercase.
- $requests_classes : array<string|int, string>
- List of all Requests classes included in WP Core.
- $requests_classes_lc : array<string|int, string>
- List of all Requests classes in lowercase.
- $simplepie_classes : array<string|int, string>
- List of all SimplePie classes included in WP Core.
- $simplepie_classes_lc : array<string|int, string>
- List of all SimplePie classes in lowercase.
- $wp_classes : array<string|int, string>
- List of all WP native classes.
- $wp_classes_lc : array<string|int, string>
- List of all WP native classes in lowercase.
- $wp_themes_classes : array<string|int, string>
- List of all WP native classes as shipped with themes included in WP Core.
- $wp_themes_classes_lc : array<string|int, string>
- List of all WP native classes as shipped with themes in lowercase.
Methods
- __construct() : mixed
- Constructor.
- check_for_matches() : int|void
- Verify if the current token is one of the targetted classes.
- getGroups() : array<string|int, mixed>
- Groups of classes to restrict.
- is_targetted_token() : bool
- Determine if we have a valid classname for the target token.
- process() : int|void
- Set sniff properties and hand off to child class for processing of the token.
- process_matched_token() : void
- Process a matched token.
- process_token() : int|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.
- get_namespaced_classname() : string
- See if the classname was found in a namespaced file and if so, add the namespace to the classname.
- prepare_name_for_regex() : string
- Prepare the class name for use in a regular expression.
- setup_groups() : bool
- Set up the regular expressions for each group.
- get_proper_case() : string
- Match a lowercase class name to its proper cased name.
Properties
$exclude
Exclude groups.
public
array<string|int, mixed>
$exclude
= array()
Example: 'switch_to_blog,user_meta'
Tags
$unittest_groups
Groups of function data to check against.
public
static array<string|int, mixed>
$unittest_groups
= array()
Don't use this in extended classes, override getGroups() instead. This is only used for Unit tests.
Tags
$classname
Temporary storage for retrieved class name.
protected
string
$classname
$excluded_groups
Cache for the excluded groups information.
protected
array<string|int, mixed>
$excluded_groups
= array()
Tags
$groups
Cache for the group information.
protected
array<string|int, mixed>
$groups
= array()
Tags
$phpcsFile
The current file being sniffed.
protected
File
$phpcsFile
Tags
$regex_pattern
Regex pattern with placeholder for the class names.
protected
string
$regex_pattern
= '`^\\\\(?:%s)$`i'
$tokens
The list of tokens in the current file being sniffed.
protected
array<string|int, mixed>
$tokens
Tags
$avif_classes
List of all AVIF classes included in WP Core.
private
array<string|int, string>
$avif_classes
= array('Avifinfo\Box', 'Avifinfo\Chan_Prop', 'Avifinfo\Dim_Prop', 'Avifinfo\Features', 'Avifinfo\Parser', 'Avifinfo\Prop', 'Avifinfo\Tile')
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$avif_classes_lc
List of all AVIF classes in lowercase.
private
array<string|int, string>
$avif_classes_lc
= array()
This array is automatically generated in the class constructor based on the $avif_classes property.
The class names in lowercase.
Tags
$class_groups
Groups names.
private
array<string|int, mixed>
$class_groups
= array('wp_classes', 'wp_themes_classes', 'avif_classes', 'getid3_classes', 'phpmailer_classes', 'requests_classes', 'simplepie_classes')
Used to dynamically fill in some of the above properties and to generate the getGroups() array.
Tags
$getid3_classes
List of all GetID3 classes included in WP Core.
private
array<string|int, string>
$getid3_classes
= array('AMFReader', 'AMFStream', 'AVCSequenceParameterSetReader', 'getID3', 'getid3_ac3', 'getid3_apetag', 'getid3_asf', 'getid3_dts', 'getid3_exception', 'getid3_flac', 'getid3_flv', 'getid3_handler', 'getid3_id3v1', 'getid3_id3v2', 'getid3_lib', 'getid3_lyrics3', 'getid3_matroska', 'getid3_mp3', 'getid3_ogg', 'getid3_quicktime', 'getid3_riff')
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$getid3_classes_lc
List of all GetID3 classes in lowercase.
private
array<string|int, string>
$getid3_classes_lc
= array()
This array is automatically generated in the class constructor based on the $phpmailer_classes property.
The class names in lowercase.
Tags
$phpmailer_classes
List of all PHPMailer classes included in WP Core.
private
array<string|int, string>
$phpmailer_classes
= array('PHPMailer\PHPMailer\Exception', 'PHPMailer\PHPMailer\PHPMailer', 'PHPMailer\PHPMailer\SMTP')
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$phpmailer_classes_lc
List of all PHPMailer classes in lowercase.
private
array<string|int, string>
$phpmailer_classes_lc
= array()
This array is automatically generated in the class constructor based on the $phpmailer_classes property.
The class names in lowercase.
Tags
$requests_classes
List of all Requests classes included in WP Core.
private
array<string|int, string>
$requests_classes
= array(
// Interfaces, Requests v1.
'Requests_Auth',
'Requests_Hooker',
'Requests_Proxy',
'Requests_Transport',
// Interfaces, Requests v2.
'WpOrg\Requests\Auth',
'WpOrg\Requests\Capability',
'WpOrg\Requests\HookManager',
'WpOrg\Requests\Proxy',
'WpOrg\Requests\Transport',
// Classes, Requests v1.
'Requests',
'Requests_Auth_Basic',
'Requests_Cookie',
'Requests_Cookie_Jar',
'Requests_Exception',
'Requests_Exception_HTTP',
'Requests_Exception_Transport',
'Requests_Exception_Transport_cURL',
'Requests_Exception_HTTP_304',
'Requests_Exception_HTTP_305',
'Requests_Exception_HTTP_306',
'Requests_Exception_HTTP_400',
'Requests_Exception_HTTP_401',
'Requests_Exception_HTTP_402',
'Requests_Exception_HTTP_403',
'Requests_Exception_HTTP_404',
'Requests_Exception_HTTP_405',
'Requests_Exception_HTTP_406',
'Requests_Exception_HTTP_407',
'Requests_Exception_HTTP_408',
'Requests_Exception_HTTP_409',
'Requests_Exception_HTTP_410',
'Requests_Exception_HTTP_411',
'Requests_Exception_HTTP_412',
'Requests_Exception_HTTP_413',
'Requests_Exception_HTTP_414',
'Requests_Exception_HTTP_415',
'Requests_Exception_HTTP_416',
'Requests_Exception_HTTP_417',
'Requests_Exception_HTTP_418',
'Requests_Exception_HTTP_428',
'Requests_Exception_HTTP_429',
'Requests_Exception_HTTP_431',
'Requests_Exception_HTTP_500',
'Requests_Exception_HTTP_501',
'Requests_Exception_HTTP_502',
'Requests_Exception_HTTP_503',
'Requests_Exception_HTTP_504',
'Requests_Exception_HTTP_505',
'Requests_Exception_HTTP_511',
'Requests_Exception_HTTP_Unknown',
'Requests_Hooks',
'Requests_IDNAEncoder',
'Requests_IPv6',
'Requests_IRI',
'Requests_Proxy_HTTP',
'Requests_Response',
'Requests_Response_Headers',
'Requests_Session',
'Requests_SSL',
'Requests_Transport_cURL',
'Requests_Transport_fsockopen',
'Requests_Utility_CaseInsensitiveDictionary',
'Requests_Utility_FilteredIterator',
// Classes, Requests v2.
'WpOrg\Requests\Auth\Basic',
'WpOrg\Requests\Autoload',
'WpOrg\Requests\Cookie',
'WpOrg\Requests\Cookie\Jar',
'WpOrg\Requests\Exception',
'WpOrg\Requests\Exception\ArgumentCount',
'WpOrg\Requests\Exception\Http',
'WpOrg\Requests\Exception\Http\Status304',
'WpOrg\Requests\Exception\Http\Status305',
'WpOrg\Requests\Exception\Http\Status306',
'WpOrg\Requests\Exception\Http\Status400',
'WpOrg\Requests\Exception\Http\Status401',
'WpOrg\Requests\Exception\Http\Status402',
'WpOrg\Requests\Exception\Http\Status403',
'WpOrg\Requests\Exception\Http\Status404',
'WpOrg\Requests\Exception\Http\Status405',
'WpOrg\Requests\Exception\Http\Status406',
'WpOrg\Requests\Exception\Http\Status407',
'WpOrg\Requests\Exception\Http\Status408',
'WpOrg\Requests\Exception\Http\Status409',
'WpOrg\Requests\Exception\Http\Status410',
'WpOrg\Requests\Exception\Http\Status411',
'WpOrg\Requests\Exception\Http\Status412',
'WpOrg\Requests\Exception\Http\Status413',
'WpOrg\Requests\Exception\Http\Status414',
'WpOrg\Requests\Exception\Http\Status415',
'WpOrg\Requests\Exception\Http\Status416',
'WpOrg\Requests\Exception\Http\Status417',
'WpOrg\Requests\Exception\Http\Status418',
'WpOrg\Requests\Exception\Http\Status428',
'WpOrg\Requests\Exception\Http\Status429',
'WpOrg\Requests\Exception\Http\Status431',
'WpOrg\Requests\Exception\Http\Status500',
'WpOrg\Requests\Exception\Http\Status501',
'WpOrg\Requests\Exception\Http\Status502',
'WpOrg\Requests\Exception\Http\Status503',
'WpOrg\Requests\Exception\Http\Status504',
'WpOrg\Requests\Exception\Http\Status505',
'WpOrg\Requests\Exception\Http\Status511',
'WpOrg\Requests\Exception\Http\StatusUnknown',
'WpOrg\Requests\Exception\InvalidArgument',
'WpOrg\Requests\Exception\Transport',
'WpOrg\Requests\Exception\Transport\Curl',
'WpOrg\Requests\Hooks',
'WpOrg\Requests\IdnaEncoder',
'WpOrg\Requests\Ipv6',
'WpOrg\Requests\Iri',
'WpOrg\Requests\Port',
'WpOrg\Requests\Proxy\Http',
'WpOrg\Requests\Requests',
'WpOrg\Requests\Response',
'WpOrg\Requests\Response\Headers',
'WpOrg\Requests\Session',
'WpOrg\Requests\Ssl',
'WpOrg\Requests\Transport\Curl',
'WpOrg\Requests\Transport\Fsockopen',
'WpOrg\Requests\Utility\CaseInsensitiveDictionary',
'WpOrg\Requests\Utility\FilteredIterator',
'WpOrg\Requests\Utility\InputValidator',
)
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$requests_classes_lc
List of all Requests classes in lowercase.
private
array<string|int, string>
$requests_classes_lc
= array()
This array is automatically generated in the class constructor based on the $requests_classes property.
The class names in lowercase.
Tags
$simplepie_classes
List of all SimplePie classes included in WP Core.
private
array<string|int, string>
$simplepie_classes
= array(
// Interfaces.
'SimplePie_Cache_Base',
// Classes.
'SimplePie',
'SimplePie_Author',
'SimplePie_Cache',
'SimplePie_Cache_DB',
'SimplePie_Cache_File',
'SimplePie_Cache_Memcache',
'SimplePie_Cache_Memcached',
'SimplePie_Cache_MySQL',
'SimplePie_Cache_Redis',
'SimplePie_Caption',
'SimplePie_Category',
'SimplePie_Content_Type_Sniffer',
'SimplePie_Copyright',
'SimplePie_Core',
'SimplePie_Credit',
'SimplePie_Decode_HTML_Entities',
'SimplePie_Enclosure',
'SimplePie_Exception',
'SimplePie_File',
'SimplePie_HTTP_Parser',
'SimplePie_IRI',
'SimplePie_Item',
'SimplePie_Locator',
'SimplePie_Misc',
'SimplePie_Net_IPv6',
'SimplePie_Parse_Date',
'SimplePie_Parser',
'SimplePie_Rating',
'SimplePie_Registry',
'SimplePie_Restriction',
'SimplePie_Sanitize',
'SimplePie_Source',
'SimplePie_XML_Declaration_Parser',
'SimplePie_gzdecode',
)
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$simplepie_classes_lc
List of all SimplePie classes in lowercase.
private
array<string|int, string>
$simplepie_classes_lc
= array()
This array is automatically generated in the class constructor based on the $simplepie_classes property.
The class names in lowercase.
Tags
$wp_classes
List of all WP native classes.
private
array<string|int, string>
$wp_classes
= array('_WP_Dependency', '_WP_Editors', '_WP_List_Table_Compat', 'AtomEntry', 'AtomFeed', 'AtomParser', 'Automatic_Upgrader_Skin', 'Bulk_Plugin_Upgrader_Skin', 'Bulk_Theme_Upgrader_Skin', 'Bulk_Upgrader_Skin', 'Core_Upgrader', 'Custom_Background', 'Custom_Image_Header', 'Featured_Content', 'File_Upload_Upgrader', 'ftp', 'ftp_base', 'ftp_pure', 'ftp_sockets', 'Gettext_Translations', 'IXR_Base64', 'IXR_Client', 'IXR_ClientMulticall', 'IXR_Date', 'IXR_Error', 'IXR_IntrospectionServer', 'IXR_Message', 'IXR_Request', 'IXR_Server', 'IXR_Value', 'Language_Pack_Upgrader', 'Language_Pack_Upgrader_Skin', 'MO', 'MagpieRSS', 'NOOP_Translations', 'PO', 'POMO_CachedFileReader', 'POMO_CachedIntFileReader', 'POMO_FileReader', 'POMO_Reader', 'POMO_StringReader', 'POP3', 'PasswordHash', 'PclZip', 'Plugin_Installer_Skin', 'Plugin_Upgrader', 'Plugin_Upgrader_Skin', 'Plural_Forms', 'RSSCache', 'Services_JSON', 'Services_JSON_Error', 'Snoopy', 'Text_Diff', 'Text_Diff_Engine_native', 'Text_Diff_Engine_shell', 'Text_Diff_Engine_string', 'Text_Diff_Engine_xdiff', 'Text_Diff_Op', 'Text_Diff_Op_add', 'Text_Diff_Op_change', 'Text_Diff_Op_copy', 'Text_Diff_Op_delete', 'Text_Diff_Renderer', 'Text_Diff_Renderer_inline', 'Text_MappedDiff', 'Theme_Installer_Skin', 'Theme_Upgrader', 'Theme_Upgrader_Skin', 'Translation_Entry', 'Translations', 'Walker', 'Walker_Category', 'Walker_CategoryDropdown', 'Walker_Category_Checklist', 'Walker_Comment', 'Walker_Nav_Menu', 'Walker_Nav_Menu_Checklist', 'Walker_Nav_Menu_Edit', 'Walker_Page', 'Walker_PageDropdown', 'WP', 'WP_Admin_Bar', 'WP_Ajax_Response', 'WP_Ajax_Upgrader_Skin', 'WP_Application_Passwords', 'WP_Application_Passwords_List_Table', 'WP_Automatic_Updater', 'WP_Block', 'WP_Block_Bindings_Registry', 'WP_Block_Bindings_Source', 'WP_Block_Editor_Context', 'WP_Block_List', 'WP_Block_Parser', 'WP_Block_Parser_Block', 'WP_Block_Parser_Frame', 'WP_Block_Pattern_Categories_Registry', 'WP_Block_Patterns_Registry', 'WP_Block_Styles_Registry', 'WP_Block_Supports', 'WP_Block_Template', 'WP_Block_Type', 'WP_Block_Type_Registry', 'WP_Classic_To_Block_Menu_Converter', 'WP_Comment', 'WP_Comment_Query', 'WP_Comments_List_Table', 'WP_Community_Events', 'WP_Customize_Background_Image_Control', 'WP_Customize_Background_Image_Setting', 'WP_Customize_Background_Position_Control', 'WP_Customize_Code_Editor_Control', 'WP_Customize_Color_Control', 'WP_Customize_Control', 'WP_Customize_Cropped_Image_Control', 'WP_Customize_Custom_CSS_Setting', 'WP_Customize_Date_Time_Control', 'WP_Customize_Filter_Setting', 'WP_Customize_Header_Image_Control', 'WP_Customize_Header_Image_Setting', 'WP_Customize_Image_Control', 'WP_Customize_Manager', 'WP_Customize_Media_Control', 'WP_Customize_Nav_Menu_Auto_Add_Control', 'WP_Customize_Nav_Menu_Control', 'WP_Customize_Nav_Menu_Item_Control', 'WP_Customize_Nav_Menu_Item_Setting', 'WP_Customize_Nav_Menu_Location_Control', 'WP_Customize_Nav_Menu_Locations_Control', 'WP_Customize_Nav_Menu_Name_Control', 'WP_Customize_Nav_Menu_Section', 'WP_Customize_Nav_Menu_Setting', 'WP_Customize_Nav_Menus', 'WP_Customize_Nav_Menus_Panel', 'WP_Customize_New_Menu_Control', 'WP_Customize_New_Menu_Section', 'WP_Customize_Panel', 'WP_Customize_Partial', 'WP_Customize_Section', 'WP_Customize_Selective_Refresh', 'WP_Customize_Setting', 'WP_Customize_Sidebar_Section', 'WP_Customize_Site_Icon_Control', 'WP_Customize_Theme_Control', 'WP_Customize_Themes_Panel', 'WP_Customize_Themes_Section', 'WP_Customize_Upload_Control', 'WP_Customize_Widgets', 'WP_Date_Query', 'WP_Debug_Data', 'WP_Dependencies', 'WP_Duotone', 'WP_Embed', 'WP_Error', 'WP_Fatal_Error_Handler', 'WP_Feed_Cache', 'WP_Feed_Cache_Transient', 'WP_Filesystem_Base', 'WP_Filesystem_Direct', 'WP_Filesystem_FTPext', 'WP_Filesystem_SSH2', 'WP_Filesystem_ftpsockets', 'WP_Font_Collection', 'WP_Font_Face', 'WP_Font_Face_Resolver', 'WP_Font_Library', 'WP_Font_Utils', 'WP_HTML_Active_Formatting_Elements', 'WP_HTML_Attribute_Token', 'WP_HTML_Open_Elements', 'WP_HTML_Processor', 'WP_HTML_Processor_State', 'WP_HTML_Span', 'WP_HTML_Tag_Processor', 'WP_HTML_Text_Replacement', 'WP_HTML_Token', 'WP_HTML_Unsupported_Exception', 'WP_HTTP_Fsockopen', 'WP_HTTP_IXR_Client', 'WP_HTTP_Proxy', 'WP_HTTP_Requests_Hooks', 'WP_HTTP_Requests_Response', 'WP_HTTP_Response', 'WP_Hook', 'WP_Http', 'WP_Http_Cookie', 'WP_Http_Curl', 'WP_Http_Encoding', 'WP_Http_Streams', 'WP_Image_Editor', 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick', 'WP_Importer', 'WP_Interactivity_API', 'WP_Interactivity_API_Directives_Processor', 'WP_Internal_Pointers', 'WP_Links_List_Table', 'WP_List_Table', 'WP_List_Util', 'WP_Locale', 'WP_Locale_Switcher', 'WP_MS_Sites_List_Table', 'WP_MS_Themes_List_Table', 'WP_MS_Users_List_Table', 'WP_MatchesMapRegex', 'WP_Media_List_Table', 'WP_Meta_Query', 'WP_Metadata_Lazyloader', 'WP_Nav_Menu_Widget', 'WP_Navigation_Block_Renderer', 'WP_Navigation_Fallback', 'WP_Network', 'WP_Network_Query', 'WP_Object_Cache', 'WP_Paused_Extensions_Storage', 'WP_Plugin_Dependencies', 'WP_Plugin_Install_List_Table', 'WP_Plugins_List_Table', 'WP_Post', 'WP_Post_Comments_List_Table', 'WP_Post_Type', 'WP_Posts_List_Table', 'WP_Privacy_Data_Export_Requests_List_Table', 'WP_Privacy_Data_Export_Requests_Table', 'WP_Privacy_Data_Removal_Requests_List_Table', 'WP_Privacy_Data_Removal_Requests_Table', 'WP_Privacy_Policy_Content', 'WP_Privacy_Requests_Table', 'WP_Query', 'WP_REST_Application_Passwords_Controller', 'WP_REST_Attachments_Controller', 'WP_REST_Autosaves_Controller', 'WP_REST_Block_Directory_Controller', 'WP_REST_Block_Pattern_Categories_Controller', 'WP_REST_Block_Patterns_Controller', 'WP_REST_Block_Renderer_Controller', 'WP_REST_Block_Types_Controller', 'WP_REST_Blocks_Controller', 'WP_REST_Comment_Meta_Fields', 'WP_REST_Comments_Controller', 'WP_REST_Controller', 'WP_REST_Edit_Site_Export_Controller', 'WP_REST_Font_Collections_Controller', 'WP_REST_Font_Faces_Controller', 'WP_REST_Font_Families_Controller', 'WP_REST_Global_Styles_Controller', 'WP_REST_Global_Styles_Revisions_Controller', 'WP_REST_Menu_Items_Controller', 'WP_REST_Menu_Locations_Controller', 'WP_REST_Menus_Controller', 'WP_REST_Meta_Fields', 'WP_REST_Navigation_Fallback_Controller', 'WP_REST_Pattern_Directory_Controller', 'WP_REST_Plugins_Controller', 'WP_REST_Post_Format_Search_Handler', 'WP_REST_Post_Meta_Fields', 'WP_REST_Post_Search_Handler', 'WP_REST_Post_Statuses_Controller', 'WP_REST_Post_Types_Controller', 'WP_REST_Posts_Controller', 'WP_REST_Request', 'WP_REST_Response', 'WP_REST_Revisions_Controller', 'WP_REST_Search_Controller', 'WP_REST_Search_Handler', 'WP_REST_Server', 'WP_REST_Settings_Controller', 'WP_REST_Sidebars_Controller', 'WP_REST_Site_Health_Controller', 'WP_REST_Taxonomies_Controller', 'WP_REST_Template_Autosaves_Controller', 'WP_REST_Template_Revisions_Controller', 'WP_REST_Templates_Controller', 'WP_REST_Term_Meta_Fields', 'WP_REST_Term_Search_Handler', 'WP_REST_Terms_Controller', 'WP_REST_Themes_Controller', 'WP_REST_URL_Details_Controller', 'WP_REST_User_Meta_Fields', 'WP_REST_Users_Controller', 'WP_REST_Widget_Types_Controller', 'WP_REST_Widgets_Controller', 'WP_Recovery_Mode', 'WP_Recovery_Mode_Cookie_Service', 'WP_Recovery_Mode_Email_Service', 'WP_Recovery_Mode_Key_Service', 'WP_Recovery_Mode_Link_Service', 'WP_Rewrite', 'WP_Role', 'WP_Roles', 'WP_Screen', 'WP_Script_Modules', 'WP_Scripts', 'WP_Session_Tokens', 'WP_Sidebar_Block_Editor_Control', 'WP_SimplePie_File', 'WP_SimplePie_Sanitize_KSES', 'WP_Site', 'WP_Site_Health', 'WP_Site_Health_Auto_Updates', 'WP_Site_Icon', 'WP_Site_Query', 'WP_Sitemaps', 'WP_Sitemaps_Index', 'WP_Sitemaps_Posts', 'WP_Sitemaps_Provider', 'WP_Sitemaps_Registry', 'WP_Sitemaps_Renderer', 'WP_Sitemaps_Stylesheet', 'WP_Sitemaps_Taxonomies', 'WP_Sitemaps_Users', 'WP_Style_Engine', 'WP_Style_Engine_CSS_Declarations', 'WP_Style_Engine_CSS_Rule', 'WP_Style_Engine_CSS_Rules_Store', 'WP_Style_Engine_Processor', 'WP_Styles', 'WP_Tax_Query', 'WP_Taxonomy', 'WP_Term', 'WP_Term_Query', 'WP_Terms_List_Table', 'WP_Text_Diff_Renderer_Table', 'WP_Text_Diff_Renderer_inline', 'WP_Textdomain_Registry', 'WP_Theme', 'WP_Theme_Install_List_Table', 'WP_Theme_JSON', 'WP_Theme_JSON_Data', 'WP_Theme_JSON_Resolver', 'WP_Theme_JSON_Schema', 'WP_Themes_List_Table', 'WP_Translation_Controller', 'WP_Translation_File', 'WP_Translation_File_MO', 'WP_Translation_File_PHP', 'WP_Translations', 'WP_Upgrader', 'WP_Upgrader_Skin', 'WP_User', 'WP_User_Meta_Session_Tokens', 'WP_User_Query', 'WP_User_Request', 'WP_User_Search', 'WP_Users_List_Table', 'WP_Widget', 'WP_Widget_Archives', 'WP_Widget_Area_Customize_Control', 'WP_Widget_Block', 'WP_Widget_Calendar', 'WP_Widget_Categories', 'WP_Widget_Custom_HTML', 'WP_Widget_Factory', 'WP_Widget_Form_Customize_Control', 'WP_Widget_Links', 'WP_Widget_Media', 'WP_Widget_Media_Audio', 'WP_Widget_Media_Gallery', 'WP_Widget_Media_Image', 'WP_Widget_Media_Video', 'WP_Widget_Meta', 'WP_Widget_Pages', 'WP_Widget_RSS', 'WP_Widget_Recent_Comments', 'WP_Widget_Recent_Posts', 'WP_Widget_Search', 'WP_Widget_Tag_Cloud', 'WP_Widget_Text', 'WP_oEmbed', 'WP_oEmbed_Controller', 'wp_atom_server', 'wp_xmlrpc_server', 'wpdb')
List is sorted alphabetically and based on a draft sniff to autogenerate this list.
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$wp_classes_lc
List of all WP native classes in lowercase.
private
array<string|int, string>
$wp_classes_lc
= array()
This array is automatically generated in the class constructor based on the $wp_classes property.
The class names in lowercase.
Tags
$wp_themes_classes
List of all WP native classes as shipped with themes included in WP Core.
private
array<string|int, string>
$wp_themes_classes
= array('TwentyNineteen_SVG_Icons', 'TwentyNineteen_Walker_Comment', 'TwentyTwenty_Customize', 'TwentyTwenty_Non_Latin_Languages', 'TwentyTwenty_SVG_Icons', 'TwentyTwenty_Script_Loader', 'TwentyTwenty_Separator_Control', 'TwentyTwenty_Walker_Comment', 'TwentyTwenty_Walker_Page', 'Twenty_Eleven_Ephemera_Widget', 'Twenty_Fourteen_Ephemera_Widget', 'Twenty_Twenty_One_Custom_Colors', 'Twenty_Twenty_One_Customize', 'Twenty_Twenty_One_Customize_Color_Control', 'Twenty_Twenty_One_Customize_Notice_Control', 'Twenty_Twenty_One_Dark_Mode', 'Twenty_Twenty_One_SVG_Icons')
Note: this list will be enhanced in the class constructor.
The class names in their "proper" case. The constructor will add the lowercased class name as a key to each entry.
Tags
$wp_themes_classes_lc
List of all WP native classes as shipped with themes in lowercase.
private
array<string|int, string>
$wp_themes_classes_lc
= array()
This array is automatically generated in the class constructor based on the $wp_themes_classes property.
The class names in lowercase.
Tags
Methods
__construct()
Constructor.
public
__construct() : mixed
Tags
check_for_matches()
Verify if the current token is one of the targetted classes.
public
check_for_matches(int $stackPtr) : int|void
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
Tags
Return values
int|void —Integer stack pointer to skip forward or void to continue normal file processing.
getGroups()
Groups of classes to restrict.
public
getGroups() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>is_targetted_token()
Determine if we have a valid classname for the target token.
public
is_targetted_token(int $stackPtr) : bool
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
Tags
Return values
boolprocess()
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
Return values
int|void —Integer stack pointer to skip forward or void to continue normal file processing.
process_matched_token()
Process a matched token.
public
process_matched_token(int $stackPtr, string $group_name, string $matched_content) : void
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
- $group_name : string
-
The name of the group which was matched. Will always be 'wp_classes'.
- $matched_content : string
-
The token content (class name) which was matched. in its original case.
Tags
process_token()
Processes this test, when one of its tokens is encountered.
public
process_token(int $stackPtr) : int|void
}
Parameters
- $stackPtr : int
-
The position of the current token in the stack.
Return values
int|void —Integer stack pointer to skip forward or void to continue normal file processing.
register()
Returns an array of tokens this test wants to listen for.
public
register() : array<string|int, mixed>
Return values
array<string|int, mixed>get_namespaced_classname()
See if the classname was found in a namespaced file and if so, add the namespace to the classname.
protected
get_namespaced_classname(string $classname, int $search_from) : string
Parameters
- $classname : string
-
The full classname as found.
- $search_from : int
-
The token position to search up from.
Return values
string —Classname, potentially prefixed with the namespace.
prepare_name_for_regex()
Prepare the class name for use in a regular expression.
protected
prepare_name_for_regex(string $classname) : string
The getGroups() method allows for providing class names with a wildcard * to target a group of classes within a namespace. It also allows for providing class names as 'ordinary' names or prefixed with one or more namespaces. This prepare routine takes that into account while still safely escaping the class name for use in a regular expression.
Parameters
- $classname : string
-
Class name, potentially prefixed with namespaces.
Return values
string —Regex escaped class name.
setup_groups()
Set up the regular expressions for each group.
protected
setup_groups(string $key) : bool
Parameters
- $key : string
-
The group array index key where the input for the regular expression can be found.
Tags
Return values
bool —True if the groups were setup. False if not.
get_proper_case()
Match a lowercase class name to its proper cased name.
private
get_proper_case(string $matched_lc) : string
Parameters
- $matched_lc : string
-
Lowercase class name.