-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify Type casting #142
Conversation
1. Assign $id_xyz = (int) $id_xyz once at top, instead of using (int) $id_xyz throughout the function 2. if Validate::isUnsignedId($id_xyz ) then there is no need to type cast (int) ($id_xyz)
if Validate::isUnsignedId($id_product) then there is no need to type cast (int) $id_product
Co-authored-by: Matthieu Rolland <matthieu.rolland@prestashop.com>
ProductComment.php
Outdated
@@ -95,27 +95,28 @@ public static function getByProduct($id_product, $p = 1, $n = null, $id_customer | |||
$validate = (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE'); | |||
$p = (int) $p; | |||
$n = (int) $n; | |||
$id_customer = (int) $id_customer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using Validate::isUnsignedId
as few lines above for $id_product
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At line 90, we have $id_customer
is an optional parameter and is assigned to null
if omitted.
I'm not sure about the logic of that case so I just let it there.
Thanks @leemyongpakvn I didn't notice any regressions during the tests. |
2. if Validate::isUnsignedId($id_xyz ) then there is no need to type cast (int) ($id_xyz)