-
-
Notifications
You must be signed in to change notification settings - Fork 204
Description
Bug Description
Similar to WordPress/WordPress-Coding-Standards#2521, all the sniffs using the AbstractFunctionCallParameterSniff abstract should be checked (and fixed if necessary) to ensure they correctly handle variable unpacking.
As an example, PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters does not handle variable unpacking correctly and throws a false positive when handling the code below:
<?php
crypt(...$args);./vendor/bin/phpcs -s --standard=PHPCompatibility --sniffs=PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters --runtime-set testVersion 8.0- test.php
FILE: test.php
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 | ERROR | The "salt" parameter for function crypt() is missing. Passing this parameter is no longer optional. The optional nature of the parameter is deprecated since PHP 5.6 and removed since PHP 8.0
| | (PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters.crypt_saltHardRequired)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In this case, instead of throwing an error, the sniff should ignore the crypt(...$args) call as PHPCS can't reliably determine the value of $args and thus how many parameters are being passed to crypt().
Action list
To Do
-
PHPCompatibility.FunctionUse.NewFunctionParameters -
PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters -
PHPCompatibility.FunctionUse.RemovedFunctionParameters -
PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters -
PHPCompatibility.IniDirectives.NewIniDirectives -
PHPCompatibility.IniDirectives.RemovedIniDirectives -
PHPCompatibility.InitialValue.NewConstantArraysUsingDefine -
PHPCompatibility.InitialValue.NewNewInDefine -
PHPCompatibility.ParameterValues.ChangedIntToBoolParamType -
PHPCompatibility.ParameterValues.ChangedObStartEraseFlags -
PHPCompatibility.ParameterValues.ForbiddenGetClassNoArgsOutsideOO -
PHPCompatibility.ParameterValues.ForbiddenGetClassNull -
PHPCompatibility.ParameterValues.ForbiddenSessionModuleNameUser -
PHPCompatibility.ParameterValues.ForbiddenStripTagsSelfClosingXHTML -
PHPCompatibility.ParameterValues.NewArrayMergeRecursiveWithGlobalsVar -
PHPCompatibility.ParameterValues.NewArrayReduceInitialType -
PHPCompatibility.ParameterValues.NewAssertCustomException -
PHPCompatibility.ParameterValues.NewFopenModes -
PHPCompatibility.ParameterValues.NewHashAlgorithms -
PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault -
PHPCompatibility.ParameterValues.NewHTMLEntitiesFlagsDefault -
PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault -
PHPCompatibility.ParameterValues.NewIDNVariantDefault -
PHPCompatibility.ParameterValues.NewNegativeStringOffset -
PHPCompatibility.ParameterValues.NewNumberFormatMultibyteSeparators -
PHPCompatibility.ParameterValues.NewPackFormat -
PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues -
PHPCompatibility.ParameterValues.NewPCREModifiers -
PHPCompatibility.ParameterValues.NewProcOpenCmdArray -
PHPCompatibility.ParameterValues.NewStripTagsAllowableTagsArray -
PHPCompatibility.ParameterValues.RemovedAssertStringAssertion -
PHPCompatibility.ParameterValues.RemovedGetClassNoArgs -
PHPCompatibility.ParameterValues.RemovedGetDefinedFunctionsExcludeDisabledFalse -
PHPCompatibility.ParameterValues.RemovedHashAlgorithms -
PHPCompatibility.ParameterValues.RemovedIconvEncoding -
PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder -
PHPCompatibility.ParameterValues.RemovedLdapConnectSignatures -
PHPCompatibility.ParameterValues.RemovedMbCheckEncodingNoArgs -
PHPCompatibility.ParameterValues.RemovedMbStrimWidthNegativeWidth -
PHPCompatibility.ParameterValues.RemovedMbstringModifiers -
PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParam -
PHPCompatibility.ParameterValues.RemovedNonCryptoHash -
PHPCompatibility.ParameterValues.RemovedPCREModifiers -
PHPCompatibility.ParameterValues.RemovedSetlocaleString -
PHPCompatibility.ParameterValues.RemovedSplAutoloadRegisterThrowFalse -
PHPCompatibility.ParameterValues.RemovedVersionCompareOperators
Want to contribute?
Leave a comment below to claim a sniff you'll be working on.
Leave another comment if nothing needs to be done for a given sniff, or create a PR if changes are necessary. PRs related to this task should preferably only contain changes for one sniff each.
Tested Against develop branch?
- I have verified the issue still exists in the
developbranch of PHPCompatibility.