Atom-beautify 未加载 php-cs-fixer 自定义配置

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

我安装了带有 PHP-CS-Fixer 插件的 Atom。我正在尝试使用一些自定义规则来应用同行大括号样式。

我试过使用 in-Atom 配置选项,但无法正常工作。我试过在 Atom 中设置 position_after_functions_and_oop_constructs 并将其放入 PHP-CS-FIXER Rules,但没有用。

因此,我为我的配置设置了自定义路径,即 C:\xampp\htdocs\myproject\atom.php_cs

配置为:

<?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)
;

它没有用,Atom 没有做适当的美化。有执行规则的想法吗?

备注:

我对以下款式感兴趣:

  public function someFunction(){ 
    // code here
}

由于美化工作不正常,程序可能 运行 出错。 您可以从命令面板 运行 Atom Beautify: Help Debug Editor 获取调试信息。
您的配置对我来说工作得很好,问题似乎出在您的命名上。

只需将 atom.php_cs 重命名为 .php_cs 并从设置中删除任何配置文件路径。

对于新手,请注意新版本需要将配置文件命名为.php-cs-fixer.php。太有趣了,我用谷歌搜索,看到了我的问题,哈哈。

确保 php-cs-fixer 与修复程序一起全局安装,并在完成所有这些更改后重新启动 Atom 以确保它已应用。

此外,新配置看起来像这样

<?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;