-
-
Notifications
You must be signed in to change notification settings - Fork 449
Fixed strlen(): Passing null to parameter in SalesRule/Model/Resource/Rule/Collection.php #3675
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
Conversation
…rce/Rule/Collection.php
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.
Strict type safe?
In our context, |
The method says
This would bypass |
That's the point, we want the error with strict type on. If we cast for scalar type, no error. If we want strict type, we shouldn't cast? In short, my arguments
What do you think? |
If we want strict types, we have to cast ... that is what php does internally w/o strict types on. "we shouldn't cast" as soon we have typed method parameters.
|
Co-authored-by: Sven Reichel <[email protected]>
I have second thought. Compare if (strlen($couponCode)) { // S0
// vs
if ($couponCode !== null && strlen($couponCode)) { //S1
// vs
if (is_scalar($couponCode) && strlen((string)$couponCode)) { //S2 If |
Mhh. With an non-scalar value (S2) should ignore that if-statement w/o throwing an error. Not? (thought is was the change about) |
This PR and PR #3775, I think an error should be thrown, it'll aid debugging. If there is a bug, it will be silent and make it hard to uncover the bug. [edit] Like PR #3774, no exception on typo, the bug lives on and quite difficult, took hours, to uncover. [edit]
This PR is to fix null deprecation, not about suppressing errors. |
…rce/Rule/Collection.php
PHP8.1 OM v20.2