
types_spaces
¶A single space or none should be around union type and intersection type operators.
space
¶spacing to apply around union type and intersection type operators.
Allowed values: 'none'
, 'single'
Default value: 'none'
space_multiple_catch
¶spacing to apply around type operator when catching exceptions of multiple
types, use null
to follow the value configured for space
.
Allowed values: 'none'
, 'single'
, null
Default value: null
Default configuration.
--- Original
+++ New
<?php
try
{
new Foo();
-} catch (ErrorA | ErrorB $e) {
+} catch (ErrorA|ErrorB $e) {
echo'error';}
With configuration: ['space' => 'single']
.
--- Original
+++ New
<?php
try
{
new Foo();
-} catch (ErrorA|ErrorB $e) {
+} catch (ErrorA | ErrorB $e) {
echo'error';}
Default configuration.
--- Original
+++ New
<?php
-function foo(int | string $x)
+function foo(int|string $x)
{
}
The rule is part of the following rule sets:
Using the @PhpCsFixer rule set will enable the types_spaces
rule with the default config.
Using the @Symfony rule set will enable the types_spaces
rule with the default config.