-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Conversation
empty($data) returns false when data is 0 (as integer), 0.0 (as float) & '0' (as string). These values should be allowed to get encrypted
Please add a test case |
@@ -356,7 +356,8 @@ public function getHashAlgorithm() | |||
*/ | |||
public function encrypt($data) | |||
{ | |||
if (empty($data)) { | |||
// 0 (as integer), 0.0 (as float) & '0' (as string) will return false, though these should be allowed | |||
if (empty($data) && !($data===0 || $data===0.0 || $data==='0')) { |
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.
This could be !is_string($data) || $data === ''
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.
@ezimuel Why we don't allow encrypt empty things?
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.
@Maks3w your proposal would allow to encrypt an empty array, though I'm not sure that's desirable. On the other hand, my solution still won't allow false values, which I'm not sure if there's a use case where you'll want to encrypt a false.
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.
@auterium !is_string(array()) // TRUE ;-)
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.
My bad. Just had my morning coffee and now my brain is properly working. I'll do the change and test case tonight after work.
@auterium Any time frame on the test cases, so I can set a milestone? |
@Maks3w, you got ahead of me, just finished the test case and was about to add it to the request. Shall I do it as a separate pull request? |
Yep, send it in a new PR |
empty($data) returns false when data is 0 (as integer), 0.0 (as float) & '0' (as string). These values should be allowed to get encrypted