Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atom-beautify not loading php-cs-fixer custom config

I have Atom installed with PHP-CS-Fixer plugin. I'm trying to use some custom rules to apply same-line braces style.

I have tried using the in-Atom config option, but couldn't make it work. I have tried setting position_after_functions_and_oop_constructs and putting it in PHP-CS-FIXER Rules in Atom, but didn't work.

Therefore, I have set a custom path to my config, which is C:\xampp\htdocs\myproject\atom.php_cs

The config is:

<?php

$finder = PhpCsFixer\Finder::create()
    //->exclude('somedir')
    //->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php'
    ->in(__DIR__)
;

return PhpCsFixer\Config::create()
    ->setRules([
        '@PSR2' => true,
        'strict_param' => false,
        'array_syntax' => ['syntax' => 'long'],
        'braces' => [
            'allow_single_line_closure' => true, 
            'position_after_functions_and_oop_constructs' => 'same'],
    ])
    ->setFinder($finder)
;

It didn't work and Atom is NOT doing a proper beautify. Any idea to enforce the rules?

Notes:

I'm interested in having the following style:

  public function someFunction(){ 
    // code here
}
  • I'm using Windows 10 as OS, Atom is IDE and have PHP-cs-fixer installed via Composer.
like image 762
Jaeger Avatar asked Feb 28 '19 23:02

Jaeger


1 Answers

Since the beautification is not working properly the programm might have run into an error. You can run Atom Beautify: Help Debug Editor from the command pallette to get Debug information.
Your config works perfectly fine for me and the problem seems to be your naming.

Simply rename your atom.php_cs to .php_cs and remove any config file path from the settings.

like image 172
Merlin Attila Fejzuli Avatar answered Nov 09 '22 12:11

Merlin Attila Fejzuli