junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

Extension stopped working with complex JSON rules #217

Closed slowpokefarm closed 3 months ago

slowpokefarm commented 3 months ago

Recently extension stopped working properly.

When I'm using complex rules settings like:

    "php-cs-fixer.rules": {
        "@PSR12": true,
        "no_extra_blank_lines": true,
        "binary_operator_spaces": {
            "default": "align_single_space",
            "operators": {
                "=>": "align_single_space_minimal"
            }
        }
    },

I receive an error:

    runAsync: spawn php
[
  "/dev/bin/php-cs-fixer.phar",
  "fix",
  "--using-cache=no",
  "--format=json",
  "--rules={\"@PSR12\":true,\"no_extra_blank_lines\":true,\"binary_operator_spaces\":{\"default\":\"align_single_space\",\"operators\":{\"=>\":\"align_single_space_minimal\"}}}",
  "--path-mode=override",
  "/tmp/pcf-tmp0.454048559428494/WebsiteController.php"
]
{
  "cwd": "/website/http",
  "shell": true
}
runAsync: error
{
  "exitCode": 16,
  "stdout": null,
  "stderr": "PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.1.2-1ubuntu2.18\nRunning analysis on 1 core sequentially.\nYou can enable parallel runner and speed up the analysis! Please see https://cs.symfony.com/doc/usage.html for more information.\nLoaded config default.\n\nIn ConfigurationResolver.php line 663:\n                                             \n  Invalid JSON rules input: \"Syntax error\".  \n                                             \n\nfix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--sequential] [--] [<path>...]\n\n"
}
runAsync: reject promise
PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.1.2-1ubuntu2.18
Running analysis on 1 core sequentially.
You can enable parallel runner and speed up the analysis! Please see https://cs.symfony.com/doc/usage.html for more information.
Loaded config default.

In ConfigurationResolver.php line 663:

  Invalid JSON rules input: "Syntax error".                                        

When I'm using simple rules like "php-cs-fixer.rules": "@PSR12", everything works ok:

runAsync: spawn php
[
  "/dev/bin/php-cs-fixer.phar",
  "fix",
  "--using-cache=no",
  "--format=json",
  "--rules=@PSR12",
  "--path-mode=override",
  "/tmp/pcf-tmp0.9332918928450025/WebsiteController.php"
]
{
  "cwd": "/website/http",
  "shell": true
}
runAsync: success
{
  "stdout": "{\"about\":\"PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.\",\"files\":[],\"time\":{\"total\":0.005},\"memory\":17.066}",
  "stderr": "PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.1.2-1ubuntu2.18\nRunning analysis on 1 core sequentially.\nYou can enable parallel runner and speed up the analysis! Please see https://cs.symfony.com/doc/usage.html for more information.\nLoaded config default.\n"
}
runAsync: resolve promise
{"about":"PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.","files":[],"time":{"total":0.005},"memory":17.066}
PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.1.2-1ubuntu2.18
Running analysis on 1 core sequentially.
You can enable parallel runner and speed up the analysis! Please see https://cs.symfony.com/doc/usage.html for more information.
Loaded config default.
RYRDU commented 3 months ago

Still having issues, v0.3.13 works fine.

junstyle commented 3 months ago

your os is linux, i can't test on linux. if v0.3.13 works fine, latest version is ok too

slowpokefarm commented 3 months ago

Works fine after update for me, thanks

RYRDU commented 3 months ago

Parsing JSON works fine, but there are new problems.

runAsync: spawn [ "c:\Users\user1\.vscode-insiders\extensions\junstyle.php-cs-fixer-0.3.16\php-cs-fixer.phar", "fix", "--using-cache=no", "--format=json", "--rules={\\"@PhpCsFixer\\":true,\\"@PSR12\\":true,\\"array_syntax\\":{\\"syntax\\":\\"short\\"},\\"blank_line_after_opening_tag\\":true,\\"blank_line_before_statement\\":{\\"statements\\":[\\"case\\",\\"continue\\",\\"default\\",\\"declare\\",\\"return\\",\\"throw\\",\\"try\\"]},\\"cast_spaces\\":{\\"space\\":\\"none\\"},\\"concat_space\\":{\\"spacing\\":\\"one\\"},\\"linebreak_after_opening_tag\\":true,\\"method_argument_space\\":{\\"on_multiline\\":\\"ensure_fully_multiline\\"},\\"no_break_comment\\":{\\"comment_text\\":\\"no break...\\"},\\"no_trailing_comma_in_list_call\\":true,\\"no_trailing_comma_in_singleline_array\\":true,\\"phpdoc_summary\\":false,\\"phpdoc_align\\":false,\\"phpdoc_no_alias_tag\\":false,\\"phpdoc_annotation_without_dot\\":true,\\"phpdoc_no_empty_return\\":true,\\"single_line_comment_style\\":{\\"comment_types\\":[\\"asterisk\\"]},\\"single_quote\\":{\\"strings_containing_single_quote_chars\\":true},\\"trailing_comma_in_multiline\\":{\\"elements\\":[]},\\"yoda_style\\":{\\"always_move_variable\\":true}}", "--path-mode=override", "C:\Users\user1\AppData\Local\Temp\pcf-tmp0.5814790718269975\Untitled-1" ] { "shell": true } runAsync: error { "exitCode": 16, "stdout": null, "stderr": "PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.3.8\r\n\r\nIn ConfigurationResolver.php line 395:\r\n \r\n The path \"break...\"},\"no_trailing_comma_in_list_call\":true,\"no_trailing_com \r\n ma_in_singleline_array\":true,\"phpdoc_summary\":false,\"phpdoc_align\":false,\"p \r\n hpdoc_no_alias_tag\":false,\"phpdoc_annotation_without_dot\":true,\"phpdoc_no_e \r\n mpty_return\":true,\"single_line_comment_style\":{\"comment_types\":[\"asterisk\"] \r\n },\"single_quote\":{\"strings_containing_single_quote_chars\":true},\"trailing_c \r\n omma_in_multiline\":{\"elements\":[]},\"yoda_style\":{\"always_move_variable\":tru \r\n e}}\" is not readable. \r\n \r\n\r\nfix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--sequential] [--] [...]\r\n\r\n" } runAsync: reject promise PHP CS Fixer 3.62.0 (1ce9e24) 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors. PHP runtime: 8.3.8

In ConfigurationResolver.php line 395:

The path "break..."},"no_trailing_comma_in_list_call":true,"no_trailing_com
ma_in_singleline_array":true,"phpdoc_summary":false,"phpdoc_align":false,"p
hpdoc_no_alias_tag":false,"phpdoc_annotation_without_dot":true,"phpdoc_no_e
mpty_return":true,"single_line_comment_style":{"comment_types":["asterisk"]
},"single_quote":{"strings_containing_single_quote_chars":true},"trailing_c
omma_in_multiline":{"elements":[]},"yoda_style":{"always_move_variable":tru
e}}" is not readable.

fix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--sequential] [--] [...]

junstyle commented 3 months ago

new version published, test again

RYRDU commented 3 months ago

Works fine after update, thanks