2

We are using both php-cs-fixer and PHPCodeSniffer tools for our coding standards. Both can be conflicted when having different rules. We were able to get a balanced result except for one rule. Warning thrown by PHP Code Sniffer :

phpcs: Opening parenthesis of a multi-line function call must be the last content on the line
phpcs: Closing parenthesis of a multi-line function call must be on a line by itself

Those 2 warnings are probably caused by PEAR.Functions.FunctionCallSignature rule. We are not able to fix this automatically with our php-cs-fixer custom configuration :

https://pastebin.com/F4fpUTek

An example of the required result :
After fixing :

$response = $this->client->post('users/authenticate', [
    'form_params' => [
        'email'    => $email,
        'password' => $password,
    ],
]);

Expected output :

$response = $this->client->post(
    'users/authenticate',
    [
        'form_params' => [
            'email'       => $email,
            'password'    => $password,
        ],
    ]
);

Is there a way to achieve the previous output ?

wlarcheveque
  • 894
  • 1
  • 10
  • 28

1 Answers1

0

I was able to fix the problem by using the adequate tools. We realized php-cs-fixer does not work as well as phpcb with PHP Codesniffer. As mentionned in the Github page :

"PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent."

https://github.com/squizlabs/PHP_CodeSniffer

We used phpcb and everything works fine now.

kuba
  • 3,670
  • 3
  • 31
  • 41
wlarcheveque
  • 894
  • 1
  • 10
  • 28