after looking into it in more detail, I, unfortunately, need to inform you that with the current capabilities of the sonar-php analyzer, we’re not able to check automatically whether a method is registered as a callback hook in WordPress.
To mitigate the false positive, there are a couple of things you can do:
Disable the rule ( Unused function parameters should be removed; php:S1172) for your WordPress project in your QualityProfile
Accept the findings in SonarCloud
Add // NOSONAR at the end of the function to not raise any issues on this line. The result would may look like this:
function do_things_when_profile_updates( $user_id, $old_user_data, $user_data ) { // NOSONAR
$old_user_email = $old_user_data->data->user_email;
$new_user_email = $user_data['user_email'];
//do further things
}
We apologize for any inconvenience this may cause.
Please feel free to share any other suggestions or
requirements you might have.
Hi there, sorry for taking so long.
To be honest, the request is fair but the amount of work that goes behind it is not small, so I am not sure it would come in any reasonable timeframe.
On a side note, there are better suppression mechanisms than NOSONAR, which is kind of the nuclear option as it silences any kind of issue on the line.