
return_type_declaration
¶There should be one or no space before colon, and one space after it in return type declarations, according to configuration.
Rule is applied only in a PHP 7+ environment.
Default configuration.
--- Original
+++ New
<?php
-function foo(int $a):string {};
+function foo(int $a): string {};
With configuration: ['space_before' => 'none']
.
--- Original
+++ New
<?php
-function foo(int $a):string {};
+function foo(int $a): string {};
With configuration: ['space_before' => 'one']
.
--- Original
+++ New
<?php
-function foo(int $a):string {};
+function foo(int $a) : string {};
The rule is part of the following rule sets:
Using the @PSR12 rule set will enable the return_type_declaration
rule with the default config.
Using the @PhpCsFixer rule set will enable the return_type_declaration
rule with the default config.
Using the @Symfony rule set will enable the return_type_declaration
rule with the default config.