-
-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
From PHPWatch: PHP 8.0: Union Types
You can declare a type as nullable by prefixing a
?sign to the type. For example, if a certain property can be astringor anull, you can declare it as?string. With PHP 8.0 Union Types,string|nullwill be functionally equivalent to?string.
Also, ? is incompatible with union types. ?string|int is not accepted.
I'd like modify Type::nullable() to detect union type and add |null instead of ?.
Alternatively, Type::union() could accept a 2nd parameter: $nullable that adds the |null
I'll create a PR if that sounds good for you.
Note: intersection types are not nullable, RFC was declined.
Metadata
Metadata
Assignees
Labels
No labels