When using PHP CS Fixer to resolve syntax errors on file save and using the Symfony rule set, any function names that are not camelCase will be corrected (as expected).
However when writing PHP Unit based tests, it's often common practice to make the function names snake_case. This normally means that PHP CS Fixer will resolve the issue automatically, even when not required.
Is there a specific annotation that can be placed above a function to prevent this?
PHP CS Fixer does not have a rule to change all function names from snake_case
to camelCase
.
However, there is a rule php_unit_method_casing
which enforces camel (or snake) case for PHPUnit test methods, and in Symfony rule set it's used with default value, which is camel case.
This is what you want to change, by overriding the rule from Symfony rule set with non-default version:
[
'php_unit_method_casing' => ['case' => 'snake_case'],
],