Reputation: 972
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 :
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 ?
Upvotes: 2
Views: 1777
Reputation: 296
For anyone using php-cs-fixer, you might be interested in the "on_multiline" option of the "method_argument_space" rule:
Defines how to handle function arguments lists that contain newlines.
https://mlocati.github.io/php-cs-fixer-configurator/#version:3.38|fixer:method_argument_space
Upvotes: 0
Reputation: 972
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.
Upvotes: 0