-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: [BaseConfig] string value is set from environment variable even if it should be int/float #5779
fix: [BaseConfig] string value is set from environment variable even if it should be int/float #5779
Conversation
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 is much cleaner, but what about null handling? I think it could be quite common to have a Config with public property $foo;
as int|null
and since no initial value was set we would end up with a string
.
This does nothing.
Not so common. I think it might be bad design. Do you really need |
Sorry, I realize my description and example were both ambiguous. I meant what if the current type is app/Config/Widget.php
namespace Config;
class Widget extends BaseConfig
{
property ?int $size = null;
}
|
… is int and float
fe778b9
to
82a5107
Compare
82a5107
to
8524bb9
Compare
It seems typed properties would solve most of the type problems. This PR is enough to the current problems. |
tests/system/Config/fixtures/.env
Outdated
SimpleConfig.float = '0.0' | ||
SimpleConfig.int = '999' |
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.
Per your #5704 (comment), this should result in strings since encapsed in quotes. However, in lines 64-65 of the tests, those are tested as float and int respectively.
Isn't it contradictory? The reason why my PR was stalled is because of trying to find a solution to that distinction (i.e., string 12 and int 12) and this PR is not addressing that.
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.
Yes, I've changed my mind.
After all, the correct type is the property type in the Config class.
But I don't recommend to use '
for int/float value, I change the test fixture.
Do not recommend to use `'` for int/float value.
@paulbalandan Can I merge this? |
@paulbalandan still keen on your final opinion. @kenjis if he is unavailable over the next 48 hours let's proceed. |
More than 48 hours have passed. We proceed. |
Description
Fixes #5688
Supersede #5704, #5691 and #5690
Checklist: