The old phpDocumentor documentation already allows for `(A|B)[]`. Dropping support for parentheses entirely would break some real-world code and (as mentioned by Alexey Gopachenko) does not actually simplify anything. Supporting parentheses for some (but not all) operators would be just confusing for users. Also parentheses (in general) are very important to make more complex type expressions readable.
Allowing only one of `|` or `&` operators would break support for nullable types at minimum. The only thing that can be maybe done, if you want to restrict the syntax somehow, is to disallow union types as operands of intersection types, i.e. to allow `(A & B) | C` but not `(A | B) & C`. Allowing `A & B | C` as a shorter way to write `(A & B) | C` can also be done, but it seems to me like an unnecessary complication. PHPStan currently only supports the version with explicit parentheses and I don't remember any user complaining about this restriction. Also such restriction can always be easily lifted in the future, but cannot be added retrospectively. On Friday, October 19, 2018 at 2:50:34 PM UTC+2, Chuck Burgess wrote: > > Hello everyone, > > There is a new PR [1] from a contributor, asking for an Intersection Type > Operator. This appears to simply use `&` akin to how `|` is used for Union > Types. > > Neither Unions nor Intersections are (yet) in the language itself, but > `string|null` Union Typing in Tags has been in wide usage for a while now. > In looking over RFCs on attempts to get these two Type Operators into the > language, it seems likely to me that the Operators chosen will be `|` and > `&` if they do ever get in. As such, I'm personally good with the choice > of `&` for Intersection Operator for Typing in Tags. > > Please keep discussion on this request on this ML thread. > > Chuck Burgess, Editor > > [1] -- https://github.com/php-fig/fig-standards/pull/1104 > -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscr...@googlegroups.com. To post to this group, send email to php-fig@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/b9908a37-eac0-4eca-af28-30f1c33a02b8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.