Update "Account Number" field type from int to string.#40
Update "Account Number" field type from int to string.#40vipin1190 wants to merge 1 commit intoWhatArmy:developfrom
int to string.#40Conversation
|
@vipin1190 I’ll take a look at it when I have some free time. Thank you for your contribution |
|
Quick Question: How will the change behave when you pass in an INT as most of the people are likely passing INT. May want to create unit test to rule out that scenario; if it throws type exception or something, either it should be handled or we should note a breaking change so people can make the right level of change in their code before they pull into their existing codebase. In most cases php handles the type casting, but it sometimes behaves differently on different platforms. I will try to pull and test it when I have the time. |
|
@ash-g-1337: For now, perhaps the best idea would be to allow both types (int and string) in the setAccountNumber method and, depending on the type, cast it to a string with additional operations such as filling in missing leading zeros and validating whether the account number meets the requirements. |
|
@vipin1190 @code2prog : Having both makes sense to allow backwards compatibility, just do the casting based on what is being passed. |
|
I was working on another project and discovered something interesting.. as of php 8.1 INT starting with leading 0 (zero) is treated as Octal number.. when you cast, it converts the value from octal.. eg. when converting 01000 it returns 512 when you cast as string. |
|
@vipin1190 @code2prog Only scenario that I ran into some code breaking was where someone had had coded the account number <-not the best practice for production code. Adding additional check for int and length as mentioned by @code2prog should be enough. |
Closes issue #39 "Account numbers with leading zeros are stripped when cast to int"