Modifying convertEmptyStringToNull function to pass variables by reference #221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Good morning,
I noticed that the convertEmptyStringToNull function in your code was not working as expected when handling variables like $lastName, $firstName, etc. The reason is that these variables are passed by value in an array to the function, so changes made in the function are not reflected in the original variables.
Issue :
The current function takes an array of values and tries to replace empty strings with null. However, since the variables are passed by value, the changes are not applied to the original variables outside the function.
Proposed solution :
Modify the function to accept a variable number of arguments per reference. So any changes made to these variables within the function will reflect on the variables themselves.
Here is the modified code:
And its use:
Benefits of this change:
I think this change could benefit the robustness and usefulness of your library. I look forward to your feedback and am open to any further discussion or changes if necessary.
Thank you for your time and consideration.
Sincerely,