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 I use the CodeSniffer rule SlevomatCodingStandard.TypeHints.UnionTypeHintFormat with `withSpaces` set to “yes.” I think this also works on intersection types, despite the name.

https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md#slevomatcodingstandardtypehintsuniontypehintformat-

coding-standard/doc/type-hints.md at master · slevomat/coding-standard

Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs - slevomat/coding-standard

GitHub
@Crell @phpfig I believe #Symfony uses no spaces, and I think this is what php-cs-fixer does.
@ramsey @phpfig Have a link for Symfony?
@Crell @phpfig They don’t call it out here, but the code example shows using it without spaces. https://symfony.com/doc/current/contributing/code/standards.html
Coding Standards (Symfony Docs)

Symfony code is contributed by thousands of developers around the world. To make every piece of code look and feel familiar, Symfony defines some coding standards that all contributions must follow. T…

Rule types_spaces - PHP Coding Standards Fixer

PHP Coding Standards Fixer