Hey #PHP. When you use union and intersection types, do you include spaces?

(RT for reach, etc. This is survey data for @phpfig. If you know of any official policies by major projects already, please note/link in the replies.)

#codingstyle #phpfig

Foo|Bar, Foo&Bar, (Foo&Bar)|Baz
59.4%
Foo | Bar, Foo & Bar, (Foo & Bar) | Baz
39.6%
Other (specify)
1%
Poll ended at .
@Crell @phpfig We follow PSR-12 which according to section 5.6 (implicitly) requires spaces around types in an exception catch block. This is seen by tooling like PHPCS as a union type, so by extension ‘normal’ union types also require spaces to consistently adhere to this rule
@NanoSector @phpfig We should unify those, definitely. I can't recall seeing multi type catches in the wild very often, though.

@Crell @phpfig We use them a lot in our code base, first example that comes to mind is our CQRS queries which can either throw a “QueryException” aka something went catastrophically wrong with the query, or ItemNotFoundException; sometimes we want to catch and act on both when we *require* a result

Can be mitigated by making them extend a common exception type, and it’s probably not remotely representative; just my 2 cents :)