You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Security/PHPFilterFunctions: add support for PHP 8.0+ named parameters
1. Changed the `$target_functions` property to contain information about the target parameter name and position.
2. Adjusted the logic in the sniff to allow for named parameters using the new PHPCSUtils 1.0.0-alpha4 `PassedParameters::getParameterFromStack()` method.
3. The parameter names used are in line with the name as per the PHP 8.0 release.
PHP itself renamed a lot of parameters in PHP 8.0. As named parameters did not exist before PHP 8.0, the parameter name as per PHP 8.0 (or above) is the only relevant name.
Also see: php/doc-en#2044
4. Updated the error messages to use the parameter name instead of its position.
As a lot of the logic is now independent of which function is called, this commit also reduces code duplication in the sniff by some logic changes.
Includes additional unit tests.
Note: in the context of named parameters, it would be advisable to rename the `MissingSecondParameter` and `MissingThirdParameter` error codes to a dynamic error code using the parameter name instead, but as that would be a BC-break, this will need to wait for the next major (if deemed worth making the change).
\FILTER_INPUT_ARRAY( $array, FILTER_DEFAULT ); // This filter ID does nothing.
58
58
filter_input_array( $array, FILTER_UNSAFE_RAW, ); // This filter ID does nothing.
59
+
60
+
// Safeguard handling of function calls using PHP 8.0+ named parameters.
61
+
filter_input(var_name: $var_name, filter: FILTER_SANITIZE_STRING, type: FILTER_DEFAULT); // OK, invalid input value for $type, but that's not our concern.
0 commit comments