-
-
Notifications
You must be signed in to change notification settings - Fork 205
Description
There are a number of sniffs which mention parameter names in the error/warning message.
As part of the preparations for PHP 8 and named parameters in function calls, a lot of parameters for PHP native functions have been renamed to more descriptive names.
As it is, the online PHP documentation has not been updated with the new names yet, though it is expected that this will happen around the release date.
To find the renamed parameters, for now, the only source would be the commits: https://github.com/php/php-src/search?q=parameter+names&type=commits and looking at the stub files in the source.
The code in existing sniffs referencing parameter names needs to be updated to use the parameter name as per PHP 8 to prevent confusing people if they use named parameters.
If there is no PR open to update the PHP docs for the renamed parameter, it is recommended to also open a PR for that: https://github.com/php/doc-en/pulls Edit: this will be handled for all docs via a script: https://github.com/php/php-tasks/issues/26#issuecomment-731939804
Task list (not necessarily complete):
To do/to review:
-
SniffHelpers -
PHPCompatibility.ParameterValues.NewAssertCustomException -
PHPCompatibility.ParameterValues.RemovedAssertStringAssertion -
PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder -
PHPCompatibility.ParameterValues.RemovedMbstringModifiers
Changes prepped:
Pulled
-
HashAlgorithmsTrait- PR New/RemovedHashAlgorithms: add support for named parameters #1394 -
PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue- PR FunctionUse/ArgumentFunctionsReportCurrentValue: various improvements #1892 -
PHPCompatibility.FunctionUse.NewFunctionParameters- PR NewFunctionParameters: add support for named parameters + bug fix #1432 -
PHPCompatibility.FunctionUse.RemovedFunctionParameters- PR RemovedFunctionParameters: add support for named parameters #1433 -
PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters- PR OptionalToRequiredFunctionParameters: add support for named parameters + bug fix #1430 -
PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters- PR RequiredToOptionalFunctionParameters: add support for named parameters #1431 -
PHPCompatibility.IniDirectives.NewIniDirectives- PR NewIniDirectives: add support for named parameters #1392 -
PHPCompatibility.IniDirectives.RemovedIniDirectives- PR RemovedIniDirectives: add support for named parameters #1393 -
PHPCompatibility.InitialValue.NewConstantArrayUsingDefine- PR NewConstantArraysUsingDefine: add tests with named parameters #1369 -
PHPCompatibility.Keywords.ForbiddenNames- PR ForbiddenNames: add support for named parameters #1405 -
PHPCompatibility.ParameterValues.ChangedIntToBoolParamType- PR ChangedIntToBoolParamType: add support for named parameters #1370 -
PHPCompatibility.ParameterValues.ChangedObStartEraseFlags- PR ChangedObStartEraseFlags: add support for named parameters #1371 -
PHPCompatibility.ParameterValues.ForbiddenGetClassNull- PR ForbiddenGetClassNull: add support for named parameters #1372 -
PHPCompatibility.ParameterValues.ForbiddenSessionModuleNameUser- PR ForbiddenSessionModuleNameUser: add support for named parameters #1373 -
PHPCompatibility.ParameterValues.ForbiddenStripTagsSelfClosingXHTML- PR ForbiddenStripTagsSelfClosingXHTML: add support for named parameters #1374 -
PHPCompatibility.ParameterValues.NewArrayReduceInitialType- PR NewArrayReduceInitialType: add support for named parameters #1375 -
PHPCompatibility.ParameterValues.NewFopenModes- PR NewFopenModes: add support for named parameters #1376 -
PHPCompatibility.ParameterValues.NewHashAlgorithms- PR New/RemovedHashAlgorithms: add support for named parameters #1394 -
PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault- PR NewHTMLEntitiesEncodingDefault: add support for named parameters #1377 -
PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault- PR NewIconvMbstringCharsetDefault: add support for named parameters #1385 -
PHPCompatibility.ParameterValues.NewIDNVariantDefault- PR NewIDNVariantDefault: add support for named parameters #1378 -
PHPCompatibility.ParameterValues.NewNegativeStringOffset- PR NewNegativeStringOffset: add support for named parameters #1379 -
PHPCompatibility.ParameterValues.NewNumberFormatMultibyteSeparators- PR NewNumberFormatMultibyteSeparators: add support for named parameters #1380 -
PHPCompatibility.ParameterValues.NewPackFormat- PR NewPackFormat: add support for named parameters #1381 -
PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues- PR NewPasswordAlgoConstantValues: add support for named parameters #1382 -
PHPCompatibility.ParameterValues.NewPCREModifiers- PR NewPCREModifiers: add support for named parameters #1396 -
PHPCompatibility.ParameterValues.NewProcOpenCmdArray- PR NewProcOpenCmdArray: add support for named parameters #1383 -
PHPCompatibility.ParameterValues.NewStripTagsAllowableTagsArray- PR NewStripTagsAllowableTagsArray: add support for named parameters #1384 -
PHPCompatibility.ParameterValues.RemovedGetDefinedFunctionsExcludeDisabledFalse- PR RemovedGetDefinedFunctionsExcludeDisabledFalse: add support for named parameters #1386 -
PHPCompatibility.ParameterValues.RemovedHashAlgorithm- PR New/RemovedHashAlgorithms: add support for named parameters #1394 -
PHPCompatibility.ParameterValues.RemovedIconvEncoding- PR RemovedIconvEncoding: add support for named parameters #1387 -
PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParam- PR RemovedMbStrrposEncodingThirdParam: add support for named parameters #1388 -
PHPCompatibility.ParameterValues.RemovedNonCryptoHash- PR RemovedNonCryptoHash: add support for named parameters #1389 -
PHPCompatibility.ParameterValues.RemovedPCREModifiers- PR RemovedPCREModifiers: add support for named parameters #1395 -
PHPCompatibility.ParameterValues.RemovedSetlocaleString- PR RemovedSetlocaleString: add support for named parameters #1390 -
PHPCompatibility.ParameterValues.RemovedSplAutoloadRegisterThrowFalse- PR RemovedSplAutoloadRegisterThrowFalse: add support for named parameters #1391
Regarding sniff names
The names of the ParameterValues sniffs often contain a parameter name in the actual sniff name too and sometimes also in the error code.
I'd like to propose to leave the sniff name/error codes alone to minimize BC-breaks as changing those can invalidate rulesets and inline ignore annotations.
If needs be, a note can be added to the class docblock annotating that the name of the parameter has changed.
Edit: For those sniffs which have modular error codes which include the parameter name, the error code will change and this should be noted in the changelog as a BC break. Sniff names will still not be changed.