-
Notifications
You must be signed in to change notification settings - Fork 56
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
Reconsider enforcement of union types over the nullable ones #288
Comments
The type declarations
A nullable type is a union. Your arguments apply to nullable types as they apply to any other union and I understand that avoiding unions is probably a good idea. However, I fail to see how this is relevant for our coding standard. I don't think we should roll back. |
Language shapes the way we think. I do not want the language (the coding standard) to force me into thinking in the broad categories of union types, I want to be able to use more expressive and specific nullable types, where necessary. In my opinion, union types in PHP are a smell, and I do not want this smell to be enforced. Note, a smell doesn't mean that something is definitely wrong but it's often a sign that something is potentially wrong. As a reader of the code, I want to be able to spot a union without applying extra effort.
Following this logic, we should enforce the alphabetical order of class member declaration. |
@morozov are you saying |
Yes. The usage of NULL often naturally reflects the nature of the model being programmed. For instance |
I'm the author of the PR so I'm biased but 100% agree with @derrabus
|
I agree that I don't feel the same amount of disgust when I see
To me it reads like "this method will return a user or null" … in case of failure? |
I do not believe that the coding standard should enforce the usage of union types over the nullable ones. From the original discussion in doctrine/orm#9886 (comment):
[...]
The text was updated successfully, but these errors were encountered: