stechstudio / Laravel-PHP-CS-Fixer

Artisan Command for FriendsOfPHP/PHP-CS_Fixer
MIT License
147 stars 28 forks source link

Package does not run and here is the details and error. #24

Closed ap-coder closed 4 years ago

ap-coder commented 4 years ago

Package does not run and here is the details and error. SYSTEM DETAILS LARAVEL 5.7 "stechstudio/laravel-php-cs-fixer": "^2.1"

vagrant@homestead:~/code$ php artisan fixer:fix --dry-run

   TypeError

  Argument 1 passed to PhpCsFixer\Config::setRules() must be of the type array, null given, called in /home/vagrant/code/vendor/stechstudio/laravel-php-cs-fixer/src/Console/FixCommand.php on line 146

  at vendor/friendsofphp/php-cs-fixer/src/Config.php:259
    255|
    256|     /**
    257|      * {@inheritdoc}
    258|      */
  > 259|     public function setRules(array $rules)
    260|     {
    261|         $this->rules = $rules;
    262|
    263|         return $this;

      +17 vendor frames
  18  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
camiloiglesias96 commented 4 years ago

Hi, @ap-coder and @schmanks i am having the same issue when i try to run the command. Exist a possible fix ?

jszobody commented 4 years ago

I just did a clean install of laravel and installed this package, can't reproduce the issue.

Have you published the config file by chance? Do you have a config/fixer.php file in your app? It sounds like your config is messed up somewhere. The error you're getting occurs when config('fixer.rules') is not an array, but as you can see in the package config file, it is definitely an array:

https://github.com/stechstudio/Laravel-PHP-CS-Fixer/blob/master/config/fixer.php

Try running php artisan tinker and then config('fixer.rules') to see what you get. You should get an array if this package is installed correctly and you haven't modified the config file.

image

It might help to dump autoload and clear your config, in case it is cached.

composer dump-autoload
php artisan config:clear
camiloiglesias96 commented 4 years ago

@jszobody it work, at least for me running this commands laravel cleaned the cache and then in my tinker console the output was the correct 👍 @ap-coder try it!

jszobody commented 4 years ago

Fantastic