'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.


Solution 1:[1]

For any newcomers, please note that the new version needs the config file to be named .php-cs-fixer.php. It's so funny that I googled, and saw my question, lol.

Make sure that php-cs-fixer is installed globally with fixer, and restart Atom after you do all these changes to make sure that it's applied.

Also, new config would look like this

<?php

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__)
;

$config = new PhpCsFixer\Config();
$config->setRules([
        '@PSR2' => true,
        'strict_param' => false,
        'array_syntax' => ['syntax' => 'long'],
        'no_spaces_around_offset' => [
          'positions' => [ "inside", "outside" ]
        ],
        'no_spaces_inside_parenthesis' => true,
        'array_indentation' => true,
        'no_extra_blank_lines' => true,
        'object_operator_without_whitespace' => true,
        'multiline_whitespace_before_semicolons' => true,
        'switch_case_space' => true,
        'indentation_type' => true,
        'blank_line_after_namespace' => true,
        "no_break_comment"=> true,
        "no_closing_tag"=> true,
        'switch_case_semicolon_to_colon' => true,
        "no_spaces_after_function_name"=> true,
        "no_trailing_whitespace"=> true,
        "no_trailing_whitespace_in_comment"=> true,
        'no_whitespace_before_comma_in_array'=> true,
        'braces' => [
            'allow_single_line_closure' => true,
            'position_after_functions_and_oop_constructs' => 'same'],
    ])
    ->setFinder($finder);
  return $config;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1