Skip to content

Conversation

@PerryvanderMeer
Copy link
Contributor

@PerryvanderMeer PerryvanderMeer commented Jan 16, 2023

Not sure if we want to go this way, but I'll give it a try.
Currently, string|null and ?string are used through eachother. For example:

I'd prefer ?string for variables with a single type, since it improves readability.
This PR replaces string|null with ?string and corrects those internal inconsistencies.
If this PR gets merged, I'll work on the other types.

@ollieread
Copy link
Contributor

I'd prefer ?string for variables with a single type, since it improves readability. This PR replaces string|null with ?string and corrects those internal inconsistencies. If this PR gets merged, I'll work on the other types.

I believe the general convention is to use the shorthand of ?string for typing within the code itself, but to use a union type in documentation. This isn't a Laravel-specific thing, but a general PHP thing.

@dammy001
Copy link
Contributor

@PerryvanderMeer These changes are not needed since doctypes have been removed in L10

@driesvints
Copy link
Member

@dammy001 not exactly. They're only removed on stubs which are published as userland code. Any internal code keeps their docblocks.

@driesvints
Copy link
Member

@PerryvanderMeer I've sent in a PR to do the opposite: #45677

In general it's good to assume that the least change needed is the way to go. Thanks

@PerryvanderMeer
Copy link
Contributor Author

@driesvints In the end that seems to be the best solution. Thanks!

@PerryvanderMeer PerryvanderMeer deleted the nullable-strings branch May 19, 2023 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants