-
Notifications
You must be signed in to change notification settings - Fork 822
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
Coerce DBBoolean to be actually be a boolean #11332
Comments
for my part i don't mind so much the mixed int|bool type as long as it's clearly stated |
You'll find a lot of the I don't think the way the data is stored in the database matters as much as it would have when these classes were originally created - despite the name starting with I'd support coercing values into stricter types across In the meantime, PHP is very happy for you to pass ints around even where the typehint is for boolean - it's happy to coerce them into bool on your behalf, so I don't think there's any need even for a |
That makes a lot of sense. Let us coerce all data into submission! |
Closing as work is being done as part of #11403 |
Description
DBBoolean
doesn't actually force its value to be a boolean. In fact, it seems to really want its value to be anint(1)
orint(0)
. This seems like an anathema as we boldly step into our glorious strongly typed future.I'm proposing that values should be coerced to be actual boolean when managed via DBBoolean.
I'm assuming we'll consider this a breaking change, so it will probably have to be in CMS 6 ... although I could imagine a straight face argument that the current implementation doesn't make any promise about whether it's going to return a bool or an int, so you probably shouldn't make an assumption either way.
Additional context or points of discussion
This is the status quo. Let's say you have a page like this.
... and this task.
You will get the following output:
Validations
The text was updated successfully, but these errors were encountered: