Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom fixer.php completely ignored #32

Open
Krunch opened this issue Jul 28, 2021 · 4 comments
Open

Custom fixer.php completely ignored #32

Krunch opened this issue Jul 28, 2021 · 4 comments

Comments

@Krunch
Copy link

Krunch commented Jul 28, 2021

I am trying to customize the config/fixer.php that this package generates to tweak some of the rules, but they are completely ignored. No matter what I change in that file, none of the changes get picked up. Also, the fixer.php still uses rule names from the old php-cs-fixer version 2. For example lowercase_constants should now be constant_case.

If I reimplement the rules as-is (no changes) inside a .php-cs-fixer.dist.php file and then run this command php artisan fixer:fix --config=.php-cs-fixer.dist.php then it clearly errors out with this error:

The rules contain unknown fixers: "lowercase_constants" (did you mean "lowercase_cast"?), "phpdoc_inline_tag" (did you mean "phpdoc_line_span"?), "psr4", "trailing_comma_in_multiline_array" (did you mean "trailing_comma_in_multiline"?).

So there seems to be 2 issues currently:

  • The optional config/fixer.php that can be generated through the package is completely ignored.
  • The rules used inside the fixer.php file haven't been updated to use the new php-cs-fixer version 3 names.
@stefandoorn
Copy link

It's not 100% ignored, because when I change the name in fixer.php I see that change. But it fully ignores the rules, always resorting to the default rules of PHP-CS-Fixer: ['@PSR12' => true];.

Inside the Resolver I added after this line:

$config = $config ?: new Config(config('fixer.config_name', 'Laravel'));

The following line:

$config->setRules($options['rules'] ?: config('fixer.rules'));

That loads the rules from fixer.rules but then indeed I run into issues with the naming of several rules as you also mentioned.

Then afterwards I have to rewrite about 10 rules to match the v3 syntax indeed.

@bubba-h57 Is this something you are working on? I'm not using this package very heavily so I'm not sure if submitting a PR without internal knowledge would be the best way of solving this.

@emyasnikov
Copy link

Can somebody look after this issue, I tried to add some rules but it didn't work as expected.

@MrMarci666
Copy link

The new config file in the PR looks good, however, it won't solve the main issue.

Adding the line what @stefandoorn provided will solve the main issue.

Inside the Resolver I added after this line:

$config = $config ?: new Config(config('fixer.config_name', 'Laravel'));

The following line:

$config->setRules($options['rules'] ?: config('fixer.rules'));

@bubba-h57
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants