When running a format inside VS code the formatting is not honoring my config rules. I am using the composer version of fixer and running on Windows 11. I can't for the life of me figure out what I am missing to get my rules to take effect?
Here is my php cs fixer config file:
`<?php
$finder = (new PhpCsFixer\Finder())
->in(DIR)
;
return (new PhpCsFixer\Config())
->setRiskyAllowed(false)
->setRules([
'@psr12' => true,
'braces_position' => [
'classes_opening_brace' => 'same_line',
'functions_opening_brace' => 'same_line',
'anonymous_functions_opening_brace' => 'same_line',
'anonymous_classes_opening_brace' => 'same_line',
'control_structures_opening_brace' => 'same_line',
],
])
->setIndent("\t")
->setFinder($finder);`
Here is the original file:
`<?php
class abc {
// not much
// to say
private const xyz = [ 'row1' => 'Hello', 'row2' => 'World!'];
private function def (string $arg1, string $arg2): void {}
}`
Running a format in VS code results in the following (note opening braces have been moved to new line):
`<?php
class abc
{
// not much
// to say
private const xyz = [ 'row1' => 'Hello', 'row2' => 'World!'];
private function def(string $arg1, string $arg2): void
{
}
}`
The output from php cs fixer in the VS code output window is:
runAsync: spawn php-cs-fixer [ "fix", "--using-cache=no", "--format=json", "--rules=\"@PSR12\"", "--path-mode=override", "C:\\Users\\dayjk\\AppData\\Local\\Temp\\pcf-tmp0.5981094540911652\\testfile.php" ] { "cwd": "c:\\Users\\dayjk\\Documents\\cs-fix-test", "shell": true } runAsync: success { "stdout": "{\"about\":\"PHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\",\"files\":[{\"name\":\"C:\\\\Users\\\\dayjk\\\\AppData\\\\Local\\\\Temp\\\\pcf-tmp0.5981094540911652\\\\testfile.php\"}],\"time\":{\"total\":0.012},\"memory\":16}", "stderr": "Unable to determine minimum PHP version supported by your project from composer.json: Failed to read file \"composer.json\".\r\nIf you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/discussions/, we will help you!\r\n\r\nPHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.1\r\nLoaded config default from \"c:\\Users\\dayjk\\Documents\\cs-fix-test\\.php-cs-fixer.php\".\r\nRunning analysis on 19 cores with 10 files per process.\r\nPaths from configuration have been overridden by paths provided as command arguments.\r\nRules from configuration have been overridden by rules provided as command argument.\r\n" } runAsync: resolve promise {"about":"PHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.","files":[{"name":"C:\\Users\\dayjk\\AppData\\Local\\Temp\\pcf-tmp0.5981094540911652\\testfile.php"}],"time":{"total":0.012},"memory":16}
Running php cs fixer from the command line, the opening braces stay on the same line:
`php-cs-fixer fix . --dry-run --diff
Unable to determine minimum PHP version supported by your project from composer.json: Failed to read file "composer.json".
If you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/discussions/, we will help you!
PHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.1
Loaded config default from "C:\Users\dayjk\Documents\cs-fix-test..php-cs-fixer.php".
Running analysis on 19 cores with 10 files per process.
Using cache file ".php-cs-fixer.cache".
Paths from configuration have been overridden by paths provided as command arguments.
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
- testfile.php
---------- begin diff ----------
--- C:\Users\dayjk\Documents\cs-fix-test\testfile.php
+++ C:\Users\dayjk\Documents\cs-fix-test\testfile.php
@@ -1,3 +1,3 @@
When running a format inside VS code the formatting is not honoring my config rules. I am using the composer version of fixer and running on Windows 11. I can't for the life of me figure out what I am missing to get my rules to take effect?
Here is my php cs fixer config file:
`<?php
$finder = (new PhpCsFixer\Finder())
->in(DIR)
;
return (new PhpCsFixer\Config())
->setRiskyAllowed(false)
->setRules([
'@psr12' => true,
'braces_position' => [
'classes_opening_brace' => 'same_line',
'functions_opening_brace' => 'same_line',
'anonymous_functions_opening_brace' => 'same_line',
'anonymous_classes_opening_brace' => 'same_line',
'control_structures_opening_brace' => 'same_line',
],
])
->setIndent("\t")
->setFinder($finder);`
Here is the original file:
`<?php
class abc {
}`
Running a format in VS code results in the following (note opening braces have been moved to new line):
`<?php
class abc
{
// not much
// to say
private const xyz = [ 'row1' => 'Hello', 'row2' => 'World!'];
}`
The output from php cs fixer in the VS code output window is:
runAsync: spawn php-cs-fixer [ "fix", "--using-cache=no", "--format=json", "--rules=\"@PSR12\"", "--path-mode=override", "C:\\Users\\dayjk\\AppData\\Local\\Temp\\pcf-tmp0.5981094540911652\\testfile.php" ] { "cwd": "c:\\Users\\dayjk\\Documents\\cs-fix-test", "shell": true } runAsync: success { "stdout": "{\"about\":\"PHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\",\"files\":[{\"name\":\"C:\\\\Users\\\\dayjk\\\\AppData\\\\Local\\\\Temp\\\\pcf-tmp0.5981094540911652\\\\testfile.php\"}],\"time\":{\"total\":0.012},\"memory\":16}", "stderr": "Unable to determine minimum PHP version supported by your project from composer.json: Failed to read file \"composer.json\".\r\nIf you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/discussions/, we will help you!\r\n\r\nPHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.5.1\r\nLoaded config default from \"c:\\Users\\dayjk\\Documents\\cs-fix-test\\.php-cs-fixer.php\".\r\nRunning analysis on 19 cores with 10 files per process.\r\nPaths from configuration have been overridden by paths provided as command arguments.\r\nRules from configuration have been overridden by rules provided as command argument.\r\n" } runAsync: resolve promise {"about":"PHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.","files":[{"name":"C:\\Users\\dayjk\\AppData\\Local\\Temp\\pcf-tmp0.5981094540911652\\testfile.php"}],"time":{"total":0.012},"memory":16}Running php cs fixer from the command line, the opening braces stay on the same line:
`php-cs-fixer fix . --dry-run --diff
Unable to determine minimum PHP version supported by your project from composer.json: Failed to read file "composer.json".
If you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/discussions/, we will help you!
PHP CS Fixer 3.95.2 Adalbertus by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.5.1
Loaded config default from "C:\Users\dayjk\Documents\cs-fix-test..php-cs-fixer.php".
Running analysis on 19 cores with 10 files per process.
Using cache file ".php-cs-fixer.cache".
Paths from configuration have been overridden by paths provided as command arguments.
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
---------- begin diff ----------
--- C:\Users\dayjk\Documents\cs-fix-test\testfile.php
+++ C:\Users\dayjk\Documents\cs-fix-test\testfile.php
@@ -1,3 +1,3 @@