squizlabs/PHP_CodeSniffer v 3.5.4
php v 7.3.16
phpcs is normal hinting but phpcbf not work

phpcbf error occur file
UserAccountLogics.php.txt
phpcbf run logs run by below command
jianghu_entertain/vendor/bin/phpcbf --standard=/var/www/jianghu_entertain/phpcs-rule/phpcs.xml /var/www/jianghu_entertain/app/Models/User/Logics/UserAccountLogics.php -p -vvv
after i remove methods containing the switch cases and then phpcbf work correctly.
I don't know it is bug or which rule cause the problems, or is comflicting rule or please tell me how to able to use phpcbf in this file.
Are you able to give me a copy of the ruleset you are using? I don't think I can figure out the conflict without it.
I'm just going through the ruleset and noticed this:
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
This is causing one of the conflicts. You disallow tab indents but you also tell the ScopeIndent sniff to use tab indents. You just need to remove the tabIndent property setting to fix this one up.
Another issue is that you've included both the Generic and PEAR ScopeIndent sniff. The PEAR one wants SWITCH statements indented differently to the Generic one, so these are also conflicting. I recommend you remove both from your ruleset. Including PSR2 or PSR12 will auto-include the right one.
I've also noticed that you've included both PSR2 and PSR12 rulesets. They aren't conflicting in this case, but they have different rules and you should really just pick one. I'd recommend removing the PSR2 standard and just keeping the newer PSR12 standard.
One you remove both these sections from your ruleset:
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
and
<rule ref="PEAR.WhiteSpace.ScopeIndent">
<!-- conflic with Generic.WhiteSpace.ScopeIndent.IncorrectExact On Switch Case Indenting -->
<exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact"/>
</rule>
Then running PHPCS over your code produces this error:
FILE: temp.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
19 | ERROR | [x] Expected 3 spaces after parameter name; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
And running the fixer applies this diff:
--- temp.php
+++ PHP_CodeSniffer
@@ -16,7 +16,7 @@
{
/**
- * @param string $type 帐变类型.
+ * @param string $type 帐变类型.
* @param array $params 扩展数据.
* @throws \Exception Exception.
* @return mixed
Does this fix your issue?
Yes it solve my problem. Thank you Very Much.