Questions tagged [php-cs-fixer]
87 questions
15
votes
3 answers
Use tab for indentation in PHP-CS-Fixer
How can I configure PHP-CS-Fixer to use tab for indentation?
I can see the indentation_type fixer
* indentation_type [@PSR2, @Symfony]
| Code MUST use configured indentation type.
But how do I configure the indentation type? If I try to set…

Joyce Babu
- 19,602
- 13
- 62
- 97
11
votes
2 answers
php cs fixer, how to run risky rules?
PHP-CS-FIXER
Hi I am using php-cs-fixer for first time. I know that we have to set a .php_cs.dist file
This is a example file that i got from the git repository of php-cs-fixer.
$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
…

Redhya
- 663
- 7
- 21
10
votes
4 answers
Fix indentation of PHP code files with php-cs-fixer
I have several hundreds of horribly indented PHP files with mixed tabs and spaces (and even mixed line endings, I suppose) I would like to fix them with php-cs-fixer v2+.
I have configured php-cs-fixer to my needs, and the code is scrubbed…

wp78de
- 18,207
- 7
- 43
- 71
10
votes
2 answers
How can I create a custom rule set for php-cs-fixer?
How to create custom ruleset to be run by fix command with option --rules=@custom?
Like @PSR1, @PSR2, @Symfony, @PHP56Migration, @PHP70Migration, @PHP71Migration are made.
Php-cs-fixer version: 2.2.3
Only by inserting into vendor code…

J. Doe
- 157
- 1
- 8
8
votes
6 answers
PHP7 Adding a slash to all standard php functions php-cs-fixer rule
Inherited a PHP7 project. The previous developer added a slash to all standard PHP functions even for \true. Is there any reason for doing this?
Some examples:
\array_push($tags, 'master');
if ($result === \true) {}
$year = \date('Y');
What is…

Yada
- 30,349
- 24
- 103
- 144
8
votes
2 answers
php-cs-fixer : keep brace on the same line of function declaration
Php cs fixer is doing :
function foobar()
{
....
}
and I want:
function foobar() {
....
}
I can't see what is the config to keep braces on the same line in my config .php_cs file, nor on https://github.com/FriendsOfPHP/PHP-CS-Fixer. I'm using…

ramsey_lewis
- 558
- 8
- 25
7
votes
4 answers
Problem with php-cs-fixer after upgrade php to version 8
After upgrade to php8 I have a problem with php-cs-fixer which I installed globally via composer. Right now I can not use php-cs-fixer because every time I get:
PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.4.*.
To…

knubbe
- 1,132
- 2
- 12
- 21
6
votes
1 answer
Symfony Finder exclude with glob
I am trying to run PHP CS Fixer, which I believe is based on Symfony (which I am not familiar with), and having a problem with excluding some paths.
My setup is below:
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
…

Dayo
- 12,413
- 5
- 52
- 67
6
votes
2 answers
Associative array align => with PHP-CS-Fixer
Should associative array => should be align with PHP-CS-Fixer ?
$array = [
1 => 'a',
'1' => 'b',
1.5 => 'c',
true => 'd',
];
or
$array = [
1 => 'a',
'1' => 'b',
1.5 => 'c',
true => 'd',
];
I didn't find filter…

Bouffe
- 770
- 13
- 37
4
votes
0 answers
Microservices monorepo w/ Prettier & linting
I have a project with 4 microservices in total, 3 in PHP and 1 in JS, in 1 monorepo. I love to use Prettier for both languages and I want to use ESLint for JS and CS Fixer for PHP to assure code quality. Right now I have a Prettier installation and…

cakeheart
- 359
- 1
- 2
- 9
4
votes
3 answers
How to auto format PHP code curly braces to new lines in VS Code
I'm currently using VS Code's latest version 1.41.1 (at the time of writing).
I've installed PHP CS Fixer to auto-format my code. However there's a behavious that I don't like. It always formats the code like this:
if (condition) {
// code...
}…

Radical_Activity
- 2,618
- 10
- 38
- 70
4
votes
0 answers
PHP-CS-Fixer - how to do not add curly braces on inline statements?
I've started to use PHP-CS-Fixer and I was wondering if there is any configuration to do not automatically add curly braces on inline statements, for example
//I want to keep this way
if (empty($var))
throw new Exception('An error…

Fantasmic
- 1,122
- 17
- 25
4
votes
0 answers
How to display the errors before php-cs-fixer corrects them in Atom?
I try to use php-cs-fixer within Atom. It works fine but I would like to see the errors before the corrections. Like this picture seen in the documentation (see at the bottom of the screen):
How to do that?

Dom
- 2,984
- 3
- 34
- 64
4
votes
8 answers
atom-beautify & php-cs-fixer
I am a new programmer and I need your help.
I'm pretty much new to Atom editor, but setup some nice packages like Atom Beautify. After using it in a html / php file I'm getting the error "Could not find 'php-cs-fixer' . The program may not be…

Muhammed Al-Awami
- 51
- 1
- 1
- 3
4
votes
3 answers
How can I get php-cs-fixer to work for a Symfony project?
I installed php-cs-fixer globally by running
$ wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer
followed by running
$ sudo chmod a+x php-cs-fixer
$ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
When I try to run…

shuba.ivan
- 3,824
- 8
- 49
- 121