Questions tagged [php-cs-fixer]
87 questions
0
votes
1 answer
php-cs-fixer does not work on visual studio
I am trying to use "php-cs-fixer" plugin with visual studio code.
I read this topic : topic
I followed all the steps. When I try to format the code, I see a brief message in the bottom tool bar "php-cs-fixer finished". But the code is not formatted…

Dom
- 2,984
- 3
- 34
- 64
0
votes
1 answer
PHP-CS-Fixer in VsCode I don't think it's formatting properly
I usually code in PHP, but I have a very simple html code and it's in a broken structure. It can get worse when I try to fix it with php-cs-fixer. It keeps some elements like "i" on the same line but moves its class down the line. Or it keeps the…

DCYılmaz
- 95
- 7
0
votes
1 answer
ignoring coding standards with php-cs-fixer?
In php_codesniffer you can ignore coding standards for a block of code thusly:
// @codingStandardsIgnoreStart
$a = ($b[$c >> 5 ] & 0x0080) &
($b[$c ] & 0x0100) & // here is a multi-line
// quote from some…

neubert
- 15,947
- 24
- 120
- 212
0
votes
1 answer
PHP const math expression: code style question, which way do you prefer?
What do you guys prefer? And Why?
And what is more readable?
public const MAX_FILE_SIZE_BYTES = 10485760; // 10 MB in Bytes
VS
public const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10mb
Both ways result in the same.
Feel free to share your opinion :)

Oliver
- 51
- 1
- 7
0
votes
1 answer
Get exit code from a Makefile command and use it as a variable in Git hook
I am currently hooking into Git's pre-push hook to run PHP CS Fixer, but I'm looking for a more less clunky way of doing it. I couldn't figure out how to pass the GNU Make command's script exit code and pass in to the Git hook script.
File…

laketuna
- 3,832
- 14
- 59
- 104
0
votes
1 answer
Remove extra lines between imports with PHP CS Fixer
Is there a rule to remove extra new lines inside import?
So change:
use Foo\Bar\A;
use Foo\Bar\B;
use Foo\Bar\C;
use Foo\Bar\D;
To this:
use Foo\Bar\A;
use Foo\Bar\B;
use Foo\Bar\C;
use Foo\Bar\D;

David Maksimov
- 369
- 5
- 17
0
votes
0 answers
php-cs-fixer - normalize array declaration
I have some code with array assignments that look like this:
$myArray['Data'] = [
'stuff' => [
'junk' => [
'my_junk' => [
'foo' => [
'the_goods' => 'some data!';
],
…

Anthony
- 36,459
- 25
- 97
- 163
0
votes
1 answer
PhpStorm: what are php-cs-fixer files and how to ignore them
I keep getting "Multiple definitions exist for class..." warnings in PhpStorm, and upon inspection, I see these a bunch of these huge php-cs-fixer files (100K+ lines) with the comment "This file is part of PHP CS Fixer.".
I found that there are…

laketuna
- 3,832
- 14
- 59
- 104
0
votes
1 answer
Uncaught Error: Class 'Symfony\CS\Config\Config' not found
I've been struggling with this all day. I got brought in to a new app and they require php-cs-fixer to be ran on all files. The project has a .php_cs file in it, but I couldn't get it work in sublime text 3 nor could I get vscode to do it.
The…

ahackney
- 534
- 6
- 14
0
votes
1 answer
php-cs-fixer - disable/modify no_superfluous_phpdoc_tags rule
I want to disable no_superfluous_phpdoc_tags rule.
/**
* Refund a list of payments.
*
* @param float $amount
* @param array $charges
*
* @throws PaymentException
*
* @return boolean
*
*/
With the rule defaults it turns the above into…

fractal5
- 2,034
- 4
- 29
- 50
0
votes
1 answer
PHP CS Fixer won't load .php-cs file in Visual Studio Code
I downloaded and installed PHP CS Fixer extension for VSCode (by junstyle) and the official php-cs-fixer-v2.phar file from https://github.com/FriendsOfPHP/PHP-CS-Fixer. I created a file named config.php-cs and pasted the reference config code in it…

Cephou
- 257
- 5
- 23
0
votes
1 answer
Disable 'phpdoc_var_without_name' option phpcsfixer
How can I disable this option from phpcsfixer?
I want to use :
/**
* @var ObjectType $object
*/
But not,
/**@var ObjectType $type*/
But phpcsfixer will remove the variable name in the first case

JessGabriel
- 1,062
- 9
- 18
0
votes
1 answer
Reorder PHPDoc / Symfony annotations with csfixer
Is there a way with php-cs-fixer to define an order for Symfony annotations/PHPDoc ?
Here is two examples of a controller method and an entity property :
/**
* @Security()
*
* @ParamConverter()
*
* @Rest\Post()
*…

Tib
- 2,553
- 1
- 27
- 46
0
votes
1 answer
How to check the parse or syntax error in Yii2 code Standard?
I have used this phpcs.xml.dist to check for code standard:
Yii 2 Web Application Framework Coding Standard