impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
344 stars 191 forks source link

test: ensure parameter types accurately reflect arguments #2721

Closed tw2113 closed 6 years ago

tw2113 commented 6 years ago
$payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' );

and

give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' );

Scrutinizer is interpreting the 3rd parameters as integers and the function expects boolean. Recommending changing the two 0's to boolean false

tw2113 commented 6 years ago

May be invalid as the intended defaults may be meant to be integer.

ravinderk commented 6 years ago

@tw2113 Third parameter contains default value and can be mixed type. So it is good to assign any type of default value to param which we want to validate.

ref: https://github.com/impress-org/give/blob/master/includes/formatting.php#L732

Let me know if you want more information on that.

Closing this issue for now.