Bug Description
I've got a legacy function named avapr_get_avatar_checkbox in one of my include files. When I enabled the WordPress.NamingConventions.PrefixAllGlobals sniff, I expected this function to be flagged. (Other "incorrect" function names are!)
Minimal Code Snippet
<?php
/**
* Foobar.
*
* @package Foo
*/
/**
* Foobar.
*/
function avapr_get_avatar_checkbox() {
}
/**
* Something else.
*/
function another_function() {
}
Minimal phpcs.xml:
<?xml version="1.0"?>
<ruleset name="Foobar">
<config name="minimum_supported_wp_version" value="4.9"/>
<rule ref="WordPress"/>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="foobar"/>
</property>
</properties>
</rule>
</ruleset>
I'd expect both function names to be flagged, but only the later one is.
Error Code
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
17 | ERROR | Functions declared by a theme/plugin should start with the
| | theme/plugin prefix. Found: "another_function".
| | (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound)
--------------------------------------------------------------------------------
Environment
| Question |
Answer |
| PHP version |
7.3.1 |
| PHP_CodeSniffer version |
3.4.0 |
| WPCS version |
2.0.0 |
| WPCS install type |
Composer project local |
Bug Description
I've got a legacy function named
avapr_get_avatar_checkboxin one of my include files. When I enabled theWordPress.NamingConventions.PrefixAllGlobalssniff, I expected this function to be flagged. (Other "incorrect" function names are!)Minimal Code Snippet
Minimal
phpcs.xml:I'd expect both function names to be flagged, but only the later one is.
Error Code
Environment