-
-
Notifications
You must be signed in to change notification settings - Fork 473
Upgrade Guide to WordPressCS 3.0.0 for Developers of external standards
If you maintain an external PHPCS standard which has WordPressCS as a dependency, you may need to update your code to be compatible with WordPressCS 3.0.0. This guide is intended to help you do so.
These changes are in addition to the changes already listed in the changelog and the ruleset maintainers/end-user upgrade guide.
Please read those documents first.
Development of the repo continues in the develop
branch.
The stable branch has been renamed from master
branch to main
.
Any local clones of the repo, scripts which update these and/or CI scripts which pull in WordPressCS may need updating to account for the branch rename.
Nearly all non-abstract classes, including the sniffs, in the WordPressCS package are now declared as final
.
The PHPCS autoloader does not always play nice with sniffs which extend other sniffs, especially if both sniffs (parent and child) are included in the same standard.
To discourage sniffs extending each other, all non-abstract classes have been made final
with the exception of four classes of which it is known that those are being extended based on a public code search.
The four exceptions are:
NamingConventions.ValidHookName
Security.EscapeOutput
Security.NonceVerification
Security.ValidatedSanitizedInput
If needs be, a sniff in an external standard can still use logic from the WordPressCS sniffs.
On the one hand, the sniff can use the new Helper
classes and traits. Keep reading to learn about those.
On the other hand, the sniff can do a preliminary check on certain data and defer to a new or pre-instantiated instance of a WordPressCS sniff for everything else.
If this change causes you insurmountable problems, please open an issue in the repo to request for a class to become non-final
and explain your use case.
A number of methods have been removed from WordPressCS in favour of equivalent or better methods in PHPCSUtils.
Not all methods in PHPCSUtils are 1-on-1 replacements. Please read the online documentation for PHPCSUtils to verify how to use these methods.
Old | New | Notes |
---|---|---|
WordPressCS\WordPress\PHPCSHelper::get_config_data() |
PHPCSUtils\BackCompat\Helper::getConfigData() |
|
WordPressCS\WordPress\PHPCSHelper::get_tab_width() |
PHPCSUtils\BackCompat\Helper::getTabWidth() |
|
WordPressCS\WordPress\PHPCSHelper::get_version() |
PHPCSUtils\BackCompat\Helper::getVersion() |
|
WordPressCS\WordPress\PHPCSHelper::ignore_annotations() |
PHPCSUtils\BackCompat\Helper::ignoreAnnotations() |
|
WordPressCS\WordPress\PHPCSHelper::set_config_data() |
PHPCSUtils\BackCompat\Helper::setConfigData() |
|
WordPressCS\WordPress\Sniff::addMessage() |
PHPCSUtils\Utils\MessageHelper::addMessage() |
|
WordPressCS\WordPress\Sniff::addFixableMessage() |
PHPCSUtils\Utils\MessageHelper::addFixableMessage() |
|
WordPressCS\WordPress\Sniff::determine_namespace() |
PHPCSUtils\Utils\Namespaces::determineNamespace() |
|
WordPressCS\WordPress\Sniff::does_function_call_have_parameters() |
PHPCSUtils\Utils\PassedParameters::hasParameters() |
|
WordPressCS\WordPress\Sniff::find_array_open_close() |
PHPCSUtils\Utils\Arrays::getOpenClose() |
|
WordPressCS\WordPress\Sniff::find_list_open_close() |
PHPCSUtils\Utils\Lists::getOpenClose() |
|
WordPressCS\WordPress\Sniff::get_declared_namespace_name() |
PHPCSUtils\Utils\Namespaces::getDeclaredName() |
|
WordPressCS\WordPress\Sniff::get_function_call_parameter() |
PHPCSUtils\Utils\PassedParameters::getParameter() |
|
WordPressCS\WordPress\Sniff::get_function_call_parameter_count() |
PHPCSUtils\Utils\PassedParameters::getParameterCount() |
|
WordPressCS\WordPress\Sniff::get_function_call_parameters() |
PHPCSUtils\Utils\PassedParameters::getParameters() |
|
WordPressCS\WordPress\Sniff::get_interpolated_variables() |
PHPCSUtils\Utils\TextStrings::getEmbeds() |
The returned array contains the full embed, not just the variable. |
WordPressCS\WordPress\Sniff::get_use_type() |
PHPCSUtils\Utils\UseStatements::getType() |
|
WordPressCS\WordPress\Sniff::is_class_constant() |
PHPCSUtils\Utils\Scopes::isOOConstant() |
|
WordPressCS\WordPress\Sniff::is_class_property() |
PHPCSUtils\Utils\Scopes::isOOProperty() |
|
WordPressCS\WordPress\Sniff::is_foreach_as() |
PHPCSUtils\Utils\Context::inForeachCondition() |
Return type is different. |
WordPressCS\WordPress\Sniff::is_short_list() |
PHPCSUtils\Utils\Lists::isShortList() / PHPCSUtils\Utils\Arrays::isShortArray() |
|
WordPressCS\WordPress\Sniff::string_to_errorcode() |
PHPCSUtils\Utils\MessageHelper::stringToErrorcode() |
|
WordPressCS\WordPress\Sniff::strip_interpolated_variables() |
PHPCSUtils\Utils\TextStrings::stripEmbeds() |
|
WordPressCS\WordPress\Sniff::strip_quotes() |
PHPCSUtils\Utils\TextStrings::stripQuotes() |
|
WordPressCS\WordPress\Sniff::valid_direct_scope() |
PHPCSUtils\Utils\Scopes::validDirectScope() |
Additionally, the following methods have been removed without replacement:
- The, previously deprecated,
WordPressCS\WordPress\Sniff::has_whitelist_comment()
method. - The unused
WordPressCS\WordPress\Sniff::get_last_ptr_on_line()
method. - The unused
WordPressCS\WordPress\Sniff::is_token_in_test_method()
method. - The no longer necessary
WordPressCS\WordPress\Sniff::init()
method. - The no longer necessary
WordPressCS\WordPress\Sniffs\DB\SlowDBQuerySniff::process_token()
method. - The no longer necessary
WordPressCS\WordPress\Sniffs\NamingConventions\ValidVariableName::isSnakeCase()
method. Use theWordPressCS\WordPress\Helpers\SnakeCaseHelper::get_suggestion()
method and compare the result as an alternative way of checking the name. - The no longer necessary
WordPressCS\WordPress\Sniffs\WP\GlobalVariablesOverrideSniff::maybe_add_error()
method.
- The
WordPressCS\WordPress\Sniff::REGEX_COMPLEX_VARS
constant has been removed. Use the PHPCSUtilsPHPCSUtils\Utils\TextStrings::stripEmbeds()
andPHPCSUtils\Utils\TextStrings::getEmbeds()
methods instead.
The following properties have been removed without replacement:
- The unused
WordPressCS\WordPress\Sniff::$hookFunctions
property. - The
WordPressCS\WordPress\Sniff::$input_superglobals
property. While not exactly the same, in most cases, thePHPCSUtils\Utils\Variables::isSuperglobalName()
method can be used as an alternative. - The
WordPressCS\WordPress\Sniffs\NamingConventions\PrefixAllGlobalsSniff::$superglobals
property. As an alternative, thePHPCSUtils\Utils\Variables::isSuperglobalName()
method can be used. - The unnecessary
WordPressCS\WordPress\Sniffs\WP\I18nSniff::$check_translator_comments
property.
Nearly all properties and methods previously contained in the WordPressCS\WordPress\Sniff
class, have been moved to dedicated Helper classes or traits, with a few having been moved to the only sniff which was using the property/method.
Additionally, some properties, which were previously contained in a sniff class, have also been moved to the Helper classes/traits.
In some cases, these properties and methods have been renamed as well.
When a method has been moved to a helper class (in contrast to a trait), the method will now be static
and will generally expect the $phpcsFile
parameter to be passed to the method. The classes themselves are final
.
When a method has been moved to a helper trait, the methods will be final
, and same as for the helper classes, the methods will now generally expect the $phpcsFile
parameter to be passed to the method.
Old | New | Notes |
---|---|---|
WordPressCS\WordPress\Sniffs\Security\EscapeOutputSniff::$customAutoEscapedFunctions |
WordPressCS\WordPress\Helpers\EscapingFunctionsTrait::$customAutoEscapedFunctions |
|
WordPressCS\WordPress\Sniffs\Security\EscapeOutputSniff::$customEscapingFunctions |
WordPressCS\WordPress\Helpers\EscapingFunctionsTrait::$customEscapingFunctions |
|
WordPressCS\WordPress\Sniffs\Security\EscapeOutputSniff::$customPrintingFunctions |
WordPressCS\WordPress\Helpers\PrintingFunctionsTrait::$customPrintingFunctions |
|
WordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff::$customSanitizingFunctions |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::$customSanitizingFunctions |
|
WordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff::$customUnslashingSanitizingFunctions |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::$customUnslashingSanitizingFunctions |
|
WordPressCS\WordPress\Sniffs\Security\ValidatedSanitizedInputSniff::$customSanitizingFunctions |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::$customSanitizingFunctions |
|
WordPressCS\WordPress\Sniffs\Security\ValidatedSanitizedInputSniff::$customUnslashingSanitizingFunctions |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::$customUnslashingSanitizingFunctions |
|
WordPressCS\WordPress\Sniff::$arrayCompareFunctions |
WordPressCS\WordPress\Helpers\ContextHelper::$arrayCompareFunctions |
The property is no longer publicly accessible. |
WordPressCS\WordPress\Sniff::$arrayWalkingFunctions |
WordPressCS\WordPress\Helpers\ArrayWalkingFunctionsHelper::$arrayWalkingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the new ArrayWalkingFunctionsHelper::is_array_walking_function() method. |
WordPressCS\WordPress\Sniff::$autoEscapedFunctions |
WordPressCS\WordPress\Helpers\EscapingFunctionsTrait::$autoEscapedFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the EscapingFunctionsTrait::is_auto_escaped_function() method. |
WordPressCS\WordPress\Sniff::$cacheDeleteFunctions |
WordPressCS\WordPress\Sniffs\DB\DirectDatabaseQuerySniff::$cacheDeleteFunctions |
|
WordPressCS\WordPress\Sniff::$cacheGetFunctions |
WordPressCS\WordPress\Sniffs\DB\DirectDatabaseQuerySniff::$cacheGetFunctions |
|
WordPressCS\WordPress\Sniff::$cacheSetFunctions |
WordPressCS\WordPress\Sniffs\DB\DirectDatabaseQuerySniff::$cacheSetFunctions |
|
WordPressCS\WordPress\Sniff::$custom_test_class_whitelist |
WordPressCS\WordPress\Helpers\IsUnitTestTrait::$custom_test_classes |
Take note of the changed property name. |
WordPressCS\WordPress\Sniff::$escapingFunctions |
WordPressCS\WordPress\Helpers\EscapingFunctionsTrait::$escapingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the EscapingFunctionsTrait::is_escaping_function() method. |
WordPressCS\WordPress\Sniff::$formattingFunctions |
WordPressCS\WordPress\Helpers\FormattingFunctionsHelper::$formattingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the new FormattingFunctionsHelper::is_formatting_function() method. |
WordPressCS\WordPress\Sniff::$hookInvokeFunctions |
WordPressCS\WordPress\Helpers\WPHookHelper::$hookInvokeFunctions |
The property is no longer publicly accessible. Use the WordPressCS\WordPress\Helpers\WPHookHelper::get_functions() method for access. |
WordPressCS\WordPress\Sniff::$minimum_supported_version |
WordPressCS\WordPress\Helpers\MinimumWPVersionTrait::$minimum_wp_version |
Take note of the changed property name. |
WordPressCS\WordPress\Sniff::$nonceVerificationFunctions |
WordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff::$nonceVerificationFunctions |
The property is now private . |
WordPressCS\WordPress\Sniff::$printingFunctions |
WordPressCS\WordPress\Helpers\PrintingFunctionsTrait::$printingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the new is_printing_function() method. |
WordPressCS\WordPress\Sniff::$safe_casts |
WordPressCS\WordPress\Helpers\ContextHelper::$safe_casts |
The property is no longer publicly accessible. Use the WordPressCS\WordPress\Helpers\ContextHelper::get_safe_cast_tokens() for access. |
WordPressCS\WordPress\Sniff::$sanitizingFunctions |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::$sanitizingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the SanitizationHelperTrait::is_sanitizing_function() method. |
WordPressCS\WordPress\Sniff::$SQLAutoEscapedFunctions |
WordPressCS\WordPress\Sniffs\DB\PreparedSQLSniff::$SQLAutoEscapedFunctions |
The property is no longer publicly accessible. |
WordPressCS\WordPress\Sniff::$SQLEscapingFunctions |
WordPressCS\WordPress\Sniffs\DB\PreparedSQLSniff::$SQLEscapingFunctions |
The property is no longer publicly accessible. |
WordPressCS\WordPress\Sniff::$test_class_whitelist |
WordPressCS\WordPress\Helpers\IsUnitTestTrait::$known_test_classes |
Take note of the changed property name. The property is also no longer publicly accessible. |
WordPressCS\WordPress\Sniff::$typeTestFunctions |
WordPressCS\WordPress\Helpers\ContextHelper::$typeTestFunctions |
The property is no longer publicly accessible. |
WordPressCS\WordPress\Sniff::$unslashingFunctions |
WordPressCS\WordPress\Helpers\UnslashingFunctionsHelper::$unslashingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the new UnslashingFunctionsHelper::is_unslashing_function() method. |
WordPressCS\WordPress\Sniff::$unslashingSanitizingFunctions |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::$unslashingSanitizingFunctions |
The property is no longer publicly accessible. A function can be checked against the list using the SanitizationHelperTrait::is_sanitizing_and_unslashing_function() method. |
WordPressCS\WordPress\Sniff::$wp_globals |
WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper::$wp_globals |
The property is no longer publicly accessible. Use the WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper::get_names() method for access or use the WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper::is_wp_global() method. |
WordPressCS\WordPress\Sniff::add_unslash_error( ... ) |
WordPressCS\WordPress\Security\ValidatedSanitizedInputSniff::add_unslash_error( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::get_array_access_key( ... ) |
WordPressCS\WordPress\Helpers\VariableHelper::get_array_access_key( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::get_array_access_keys( ... ) |
WordPressCS\WordPress\Helpers\VariableHelper::get_array_access_keys( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::get_list_variables( $stackPtr, $list_open_close = array() ) |
WordPressCS\WordPress\Helpers\ListHelper::get_list_variables( File $phpcsFile, $stackPtr ) |
|
WordPressCS\WordPress\Sniff::get_snake_case_name_suggestion( ... ) |
WordPressCS\WordPress\Helpers\SnakeCaseHelper::get_suggestion( ... ) |
|
WordPressCS\WordPress\Sniff::get_wp_version_from_cl() |
WordPressCS\WordPress\Helpers\MinimumWPVersionTrait::set_minimum_wp_version() |
Take note of the changed method name. |
WordPressCS\WordPress\Sniff::has_nonce_check() |
WordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff::has_nonce_check() |
The method is now private . |
WordPressCS\WordPress\Sniff::is_assignment( $stackPtr ) |
WordPressCS\WordPress\Helpers\VariableHelper::is_assignment( File $phpcsFile, $stackPtr, $include_coalesce = true ) |
|
WordPressCS\WordPress\Sniff::is_class_object_call( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::has_object_operator_before( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_comparison( ... ) |
WordPressCS\WordPress\Helpers\VariableHelper::is_comparison( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_function_deprecated( ... ) |
WordPressCS\WordPress\Helpers\DeprecationHelper::is_function_deprecated( ... ) |
|
WordPressCS\WordPress\Sniff::is_in_array_comparison( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::is_in_array_comparison( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_in_function_call( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::is_in_function_call( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_in_isset_or_empty( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::is_in_isset_or_empty( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_in_type_test( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::is_in_type_test( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_only_sanitized( ... ) |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::is_only_sanitized( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_safe_casted( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::is_safe_casted( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_sanitized( int $stackPtr, bool $require_unslash = false ) |
WordPressCS\WordPress\Helpers\SanitizationHelperTrait::is_sanitized( File $phpcsFile, int $stackPtr, ?callable $unslash_callback = null ) |
The $unslash_callback parameter is still optional and when not passed, the behaviour is unchanged and no check for missing unslashing is executed. When passed, it now expects a callback to handle variables which are not unslashed. |
WordPressCS\WordPress\Sniff::is_test_class( ... ) |
WordPressCS\WordPress\Helpers\IsUnitTestTrait::is_test_class( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_token_namespaced( ... ) |
WordPressCS\WordPress\Helpers\ContextHelper::is_token_namespaced( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_use_of_global_constant( ... ) |
WordPressCS\WordPress\Helpers\ConstantsHelper::is_use_of_global_constant( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::is_wpdb_method_call( ... ) |
WordPressCS\WordPress\Helpers\WPDBTrait::is_wpdb_method_call( File $phpcsFile, ... ) |
|
WordPressCS\WordPress\Sniff::merge_custom_array( ... ) |
WordPressCS\WordPress\Helpers\RulesetPropertyHelper::merge_custom_array( ... ) |
The following helper classes/traits are considered internal to WordPressCS and have no promise of backwards compatibility. Use these at your own risk.
WordPressCS\WordPress\Helpers\ConstantsHelper
WordPressCS\WordPress\Helpers\ContextHelper
WordPressCS\WordPress\Helpers\DeprecationHelper
WordPressCS\WordPress\Helpers\ListHelper
WordPressCS\WordPress\Helpers\RulesetPropertyHelper
WordPressCS\WordPress\Helpers\SanitizationHelperTrait
WordPressCS\WordPress\Helpers\SnakeCaseHelper
WordPressCS\WordPress\Helpers\VariableHelper
Three significant changes have been made to the AbstractArrayAssignmentRestrictionsSniff
:
The array format expected to be returned by the getGroups()
method previously included an optional 'callback'
key which allowed for passing a callable as a validation method for that specific group.
As the callback()
method in the abstract is declared as an abstract
method, the callback
key was in practice never used as the method had to be declared in a child class anyway.
For that reason, support for this unused optional key has now been removed.
Sniffs which extend this abstract can still use different logic for different groups by applying a switch to the $group
parameter received in the callback()
, along the lines of:
public function callback( $key, $val, $line, $group ) {
switch( $group ) {
case 'groupA':
return $this->callback_for_group_A($key, val, $line);
case 'groupB':
return $this->callback_for_group_B($key, val, $line);
}
}
Previously, any string quotes around the value of the $val
parameter passed to the callback()
method would be stripped prior to passing the parameter.
This is no longer the case as it was wrong. The value for the $val
parameter may be build up of multiple tokens concatenated together and removing surrounding string quotes could lead to weird/incorrect values being passed.
It also inhibited the callback()
from determining the type of the value passed.
If you maintain sniffs which extend the AbstractArrayAssignmentRestrictionsSniff
class, please review your callback()
method and adjust it to allow for this change.
If you want to retain the old behaviour, add the following code at the top of your callback()
method:
public function callback( $key, $val, $line, $group ) {
$val = \PHPCSUtils\Utils\TextStrings::stripQuotes( $val );
// ... your code
}
The value passed to the callback()
method could previously include comments, new lines and other extraneous whitespace.
The value will now be cleaned of these before it is passed to the callback()
method.
- The optional
whitelist
key in the$groups
array has been renamed toallow
.
- The sniff now extends the WordPressCS
Sniff
class and no longer extends the upstream PEAR sniff. - The whole sniff has been refactored and all methods renamed.
- The sniff now extends the
AbstractFunctionRestrictionsSniff
class (wasSniff
). - The whole sniff has been refactored.
- This sniff has received extensive changes. New methods have been introduced, method parameters have changed etc. In case you extend this sniff, please review the changes carefully.
- The sniff now extends the
AbstractFunctionParameterSniff
class (wasAbstractFunctionRestrictionsSniff
). - The whole sniff has been refactored.
- This sniff no longer checks function/closure declarations.
These changes will only affect external standards which extend
sniffs from WordPressCS.
Renamed private
methods/properties are not mentioned as they don't impact extenders.
Sniff | Visibility | Old Name | New Name |
---|---|---|---|
WordPressCS\WordPress\Sniffs\NamingConventions\PrefixAllGlobalsSniff |
protected |
$whitelisted_core_hooks |
$allowed_core_hooks |
WordPressCS\WordPress\Sniffs\NamingConventions\PrefixAllGlobalsSniff |
protected |
$whitelisted_core_constants |
$allowed_core_constants |
WordPressCS\WordPress\Sniffs\NamingConventions\PrefixAllGlobalsSniff |
protected |
$prefix_blacklist |
$prefix_blocklist |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidFunctionNameSniff |
protected |
processTokenOutsideScope() |
process_function_declaration() |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidFunctionNameSniff |
protected |
processTokenWithinScope() |
process_method_declaration() |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidPostTypeSlugSniff |
public |
POST_TYPE_CHARACTER_WHITELIST |
VALID_POST_TYPE_CHARACTERS |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidVariableNameSniff |
protected |
$whitelisted_mixed_case_member_var_names |
$allowed_mixed_case_member_var_names |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidVariableNameSniff |
public |
$customPropertiesWhitelist |
$allowed_custom_properties |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidVariableNameSniff |
protected |
mergeWhiteList() |
merge_allow_lists() |
WordPressCS\WordPress\Sniffs\PHP\IniSetSniff |
protected |
$whitelisted_options |
$safe_options |
WordPressCS\WordPress\Sniffs\PHP\IniSetSniff |
protected |
$blacklisted_options |
$disallowed_options |
WordPressCS\WordPress\Sniffs\PHP\NoSilencedErrorsSniff |
public |
$use_default_whitelist |
$usePHPFunctionsList |
WordPressCS\WordPress\Sniffs\PHP\NoSilencedErrorsSniff |
public |
$custom_whitelist |
$customAllowedFunctionsList |
WordPressCS\WordPress\Sniffs\PHP\NoSilencedErrorsSniff |
protected |
$function_whitelist |
$allowedFunctionsList |
The array contents/format of various (protected
) array properties in sniffs has changed to support named arguments in function calls.
If your standard extends a WordPressCS sniff and overloads or uses these properties, please review the changes carefully and update your code accordingly.
This affects, amongst others, the following properties:
WordPressCS\WordPress\Sniffs\PHP\StrictInArraySniff::$target_functions
WordPressCS\WordPress\Sniffs\Security\PluginMenuSlugSniff::$target_functions
WordPressCS\WordPress\Sniffs\Utils\I18nTextDomainFixerSniff::$target_functions
WordPressCS\WordPress\Sniffs\WP\DeprecatedParametersSniff::$target_functions
WordPressCS\WordPress\Sniffs\WP\DeprecatedParameterValuesSniff::$target_functions
WordPressCS\WordPress\Sniffs\WP\DiscouragedConstantsSniff::$target_functions
A number of function parameters have been renamed to not overlap with reserved keywords.
If your external standard already started using function calls with named arguments, your function calls may need updating. Other than that, these renames should have no impact.
Class | Visibility | Old signature | New Signature |
---|---|---|---|
WordPressCS\WordPress\AbstractFunctionRestrictionsSniff |
protected |
prepare_name_for_regex( $function ) |
prepare_name_for_regex( $function_name ) |
WordPressCS\WordPress\Sniff |
protected |
is_in_function_call( $stackPtr, $valid_functions, $global = true, $allow_nested = false ) |
is_in_function_call( $stackPtr, $valid_functions, $global_function = true, $allow_nested = false ) |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidHookNameSniff |
protected |
transform( $string, $regex, $transform_type = 'full' ) |
transform( $text_string, $regex, $transform_type = 'full' ) |
WordPressCS\WordPress\Sniffs\NamingConventions\ValidHookNameSniff |
protected |
transform_complex_string( $string, $regex, $transform_type = 'full' ) |
transform_complex_string( $text_string, $regex, $transform_type = 'full' ) |
- The visibility of the
$ignored_tokens
property in theWordPressCS\WordPress\Sniffs\DB\PreparedSQLSniff
class has been changed fromprotected
toprivate
. - The visibility of the
$condition_start_tokens
property in theWordPressCS\WordPress\Sniffs\PHP\YodaConditionsSniff
class has been changed fromprotected
toprivate
. - The visibility of the
$addedCustomFunctions
property in theWordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff
class has been changed fromprotected
toprivate
, the format of the array has changed and the property has been renamed$addedCustomNonceFunctions
. - The visibility of the
$allowed_local_streams
,$allowed_local_stream_partials
and$allowed_local_stream_constants
properties in theWordPressCS\WordPress\Sniffs\WP\AlternativeFunctionsSniff
class has been changed fromprotected
toprivate
.