Open palansher opened 1 year ago
And yes, vs code extension output has nothing suspicious if I "format current file":
[
"fix",
"--using-cache=no",
"--format=json",
"--config=/home/vladp/dev/gtdev-advert/.php-cs-fixer.php",
"--allow-risky=yes",
"--path-mode=override",
"/tmp/pcf-tmp0.7450716497125385/FrontController.php"
]
{"files":[],"time":{"total":0.031},"memory":16}
Loaded config default from "/home/vladp/dev/gtdev-advert/.php-cs-fixer.php".
Paths from configuration file have been overridden by paths provided as command arguments.
Dear @palansher
Did you solve this problem?
I can confirm, that the CLI and the extension use the same config File which is placed in my project root folder and named .php-cs-fixer.php
.
We use @PSR12
standard but position_after_functions_and_oop_constructs
at the same line. Looks like it uses only @PSR12
without our adjustments.
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = Finder::create()
->in([
__DIR__ . '/app',
__DIR__ . '/config',
__DIR__ . '/database',
__DIR__ . '/resources',
__DIR__ . '/routes',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return (new Config('Extranet Laravel Rules'))
->setRules([
'@PSR12' => true,
'braces' => [
'position_after_functions_and_oop_constructs' => 'same',
]
])
->setFinder($finder)
->setRiskyAllowed(true)
->setUsingCache(true);
Hello, Stefano!
Did you solve this problem?
Unfortunately, I was not.
Thank you for your example. Maybe author will pay attention to provided details.
Well I think I possibly found the issue. If I'm using the friends-of-php/cs-fixer v 2.x (due some project restrictions to PHP 7.4) everything worked and after using the VSCode Extension with "build in" cs-fixer binary, my configuration was not correctly applied.
Id turned out, that the cs-fixer versions where different and so the name of some deprecated rule names. Thats why it applied the PSR12 rules but not those for the braces on the same line.
Maybe you can check that for yourself again :)
If I'm using the friends-of-php/cs-fixer v 2.x (due some project restrictions to PHP 7.4) everything worked
Great! You gave a hope. I will record that.
Now after two years, I am focused on DevOps and currently even have no PHP environment to check :) Excuse me, my friend. I will surely use your experience when return to the dev community.
Just to clear up any ambiguities. The problem could be that a different php-cs-fixer version is used in the extension than the one installed in the /vendor/ folder. The extension comes with its own php-cs-fixer version.
Thanks for the feedback and in this case good luck for the future :)
Good day!
Thank you for great extension!
The problem:
I get different results for formatting. Maybe extension does not pay attention to rulesets in the provided config file ?
For example, in such cli I get correct results:
But in VS Code (formatting, ) I got less rules applied for the same PHP file.. i.e. after formatting in VSCODE (and saving file, for sure), the CLI version founds to format something more (extra).
Is it known feature/bug? Is it possible to get same result with same config file for CLI and VSCODE extension methods?
If you interested, I can provide some example PHP file.
The Environment is:
VS Code config settings are (workspace):
php cs fixer ext ver: v0.3.8 PHP CS Fixer 3.13.1 Oliva by Fabien Potencier and Dariusz Ruminski. PHP runtime: 8.1.13 ubuntu 20.04 vscode ver: 1.74.2
.php-cs-fixer.php in workspace root: