Questions tagged [php-cs-fixer]

87 questions
2
votes
1 answer

Possible to align sequence of align operators?

Is there a rule in PHP-CS-FIXER 2.15.3 to align a sequence of equal symbols? For example to change $a = 3; $codeWord = 4; $foo = 'xyz'; into $a = 3; $codeWord = 4; $foo = 'xyz'; ? I have read almost every…
Adam
  • 25,960
  • 22
  • 158
  • 247
2
votes
0 answers

The grumphp precommit does not detect any errors

I cannot get grumphp to work in a subdirectory. My directory structure is below : /api/grumphp.yml /api/composer.json /api/src/ grumphp.yml contents: parameters: git_dir: ../. bin_dir: vendor/bin ascii: failed: ~ …
2
votes
2 answers

How to use other file extensions in php-cs-fixer, for example .ctp?

How to use other file extensions in php-cs-fixer, for example cakephp template .ctp files ? I have trying this code: notPath('bootstrap/cache') ->notPath('storage') ->notPath('vendor') …
Salines
  • 5,674
  • 3
  • 25
  • 50
2
votes
1 answer

How to run php-cs-fixer from code?

I am writing a PHP command line app which generates some PHP code and wants to pass it thought the code style fixer before storing it to a file. Is it possible to use php-cs-fixer as a library and call it from the code ? If no, is there any other…
webNeat
  • 2,768
  • 1
  • 20
  • 22
2
votes
2 answers

PHP-CS-FIXER is ignoring my config

I have created a file called .gm_cs in the root of my project and php-cs-fixer is installed globally. In the config file is the following true, 'combine_consecutive_unsets' => true, …
jsnfwlr
  • 3,638
  • 2
  • 23
  • 25
1
vote
0 answers

How can I configure phpcbf or phpcsfixer in Neovim using null-ls to indent code using 2 spaces?

I have read the documentation from both formatters and have tried different configurations using various coding styles with different arguments with no success. Here's a code snippet of how my configuration currently stands. local present, null_ls =…
1
vote
1 answer

Exception when directory does not exist

The issue is that if watching multiple directories via the Finder class. If one does not exist, the Finder will throw an exception and the fixer will die. $finder = Finder::create() ->in([ __DIR__ . '/web/app/mu-plugins/ys-*', …
ruckie
  • 149
  • 14
1
vote
0 answers

How to undo after php-cs-fixer

I am looking for a way to undo php-cs-fixer fix I did ./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -v --diff and a whole files on project fixed indent. Is there any way to restore the original files?
conny
  • 119
  • 1
  • 7
1
vote
2 answers

How do I prevent PHP CS Fixer from fixing specific function names?

When using PHP CS Fixer to resolve syntax errors on file save and using the Symfony rule set, any function names that are not camelCase will be corrected (as expected). However when writing PHP Unit based tests, it's often common practice to make…
Joe
  • 13
  • 4
1
vote
1 answer

Fixing function multiline arguments to a certain structure using phpcs or php-cs-fixer

I'm working on a project which developed many developers for many years, and as it often happens there is no coding standard. There are many code blocks which in general is similar but written in a different way. For example: return…
Serhii Popov
  • 3,326
  • 2
  • 25
  • 36
1
vote
1 answer

How to not modify some comments by php-cs-fixer?

I have this kind of annotation in php files, to build my swagger : /** * @OA\Get( * path="/additional_roles", * tags={"additional_roles"}, * summary="Get list of additional roles", * description="Returns list of additional…
Dom
  • 2,984
  • 3
  • 34
  • 64
1
vote
0 answers

Php cs fixer new line after array brace

We have simple array like this return ['env' => 'release', 'mode' => 'normal', 'theme' => 'basic', 'redis' => require __DIR__.'/redis.php', ]; How to add new line after(blank line) after array brace example return [ // new line after brace …
Alma Z
  • 244
  • 2
  • 10
1
vote
1 answer

Leave empty line breaks PHP CS Fixer

In my code I prefer to have more than a single line break between methods inside a class to make browsing code a little easier, and I've tried a bunch of rules that sound related to keeping/removing white space, but I cannot find a rule to ignore…
Novocaine
  • 4,692
  • 4
  • 44
  • 66
1
vote
1 answer

Closing parenthesis of a multi-line function call must be on a line by itself

I am getting this message from phpcs. my code is: $userdata["expirydate"] = date("Y-m-d H:i:s", mktime(date("H"), date( "i"), date("s"), date("m"), date("d") - 1, date("y")));
Hemant
  • 133
  • 1
  • 3
  • 9
1
vote
1 answer

PHP CS Fixer order use statements by length in PhpStorm throwing error

So recently I have seen many developers in the PHP community ordering their use statements by length. I always wondered how to do this in PhpStorm. I think I have finally found a solution but I guess I am doing something wrong here and it is not…
Rohan
  • 13,308
  • 21
  • 81
  • 154