Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Code Style Fixer: put space between colon and method's return type

Is there a PHP CS Fixer fixer available that will put space between colon and return type? Fixer should correct this signature:

public function modifyFeatureFlags(array $feature_flags):array
{
}

to:

public function modifyFeatureFlags(array $feature_flags): array
{
}

The list of available fixers is long, and I have hard time finding the correct one.

like image 742
Ilija Avatar asked Sep 17 '26 15:09

Ilija


2 Answers

From README.md

return_type_declaration [@Symfony]

There should be one or no space before colon and one space after it in return type declaration.

Try it out

like image 182
keradus Avatar answered Sep 20 '26 04:09

keradus


As stated by @keradus, there is return_type_declaration for that.

If you (or anyone else) would like to use a sniff for PHP_CodeSniffer, there is ReturnTypeHintSpacingSniff from slevomat/coding-standard.

like image 41
Tomas Votruba Avatar answered Sep 20 '26 05:09

Tomas Votruba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!