Questions tagged [phpcs]

A component of Php Code Sniffer Package, phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.

Useful links:

203 questions
6
votes
1 answer

Ignoring single PHPCS rule when running from command line

Scenario Some times, I want to run PHPCS, but have it ignore one rule, in this case the Camel Case Method Name rule. I know that I can create a new ruleset which inherits all from another ruleset, and excludes one, but I'd like to do this from the…
Alec
  • 1,986
  • 4
  • 23
  • 47
5
votes
5 answers

Visual Studio Code - PHPCS error (Unknown error ocurred. Please verify that returns a valid json object)

I am trying to set up the PHPCS plugin, but so far I am only getting this error: phpcs: Unknown error ocurred. Please verify that /home/[user]/Documents/offprojects/vet_direct/vetsdirectapp/vendor/bin/phpcs --report=json -q --encoding=UTF-8…
Sasha
  • 8,521
  • 23
  • 91
  • 174
5
votes
3 answers

PHPcs xml config disable some rules

I understand how phpcs is configurated with xml, but can not find how I disable some sniffs. This ist my current conf (don‘t even know if this is correct):
muuvmuuv
  • 901
  • 2
  • 13
  • 39
5
votes
1 answer

phpcs --standard=PHPCompatibility not working

I've followed all the steps from the official git page for installing and configure PHPCompatibility for checking the compatibility of my code with PHP7 as described bellow: Installation of PHP_CodeSniffer using pear. Download and extraction of the…
natali
  • 125
  • 2
  • 9
5
votes
2 answers

Run PHP CS fixer with GrumPHP

I'm using GrumPhp to sniff my commit in my symfony project: https://github.com/phpro/grumphp Here is my config: parameters: git_dir: . bin_dir: vendor/bin tasks: phpcsfixer: config_file: ~ config: sf23 …
Kevin
  • 4,823
  • 6
  • 36
  • 70
5
votes
1 answer

git filter-branch get only changed files?

We want to run git filter-branch over a large codebase reformatting PHP files. Since we have over 21k commits phpcbf wants to format the whole codebase every commit of filter-branch. Is it possible to get just the files that have changed for each…
Elliot Chance
  • 5,526
  • 10
  • 49
  • 80
4
votes
1 answer

phpcs with VScode - how do I disable the line length warning?

I am working on some legacy code, and VScode is highlighting a lot of lines because of some warnings like Line exceeds 85 characters, contains 91 characters. It's pretty annoying, and I'd like to raise that limit to at least 120 chars, or even…
ToX 82
  • 1,064
  • 12
  • 35
4
votes
2 answers

How to find phpcs current default standard

I want to know my current PHPCS standard in Visual Studio e.g: { "phpcs.standard": "PSR2" } how to set it is given in the documentation phpcs --config-set default_standard value
lokender singh
  • 829
  • 9
  • 18
4
votes
1 answer

PHPCS setup in Visual studio code

I want to add phpcs CodeSniffer in VScode. I'm getting an error phpcs: Request workspace/configuration failed with message: Unable to locate phpcs. Please add phpcs to your global path or use composer dependency manager to install it in your project…
Husna
  • 1,286
  • 4
  • 19
  • 48
4
votes
1 answer

Error with PHP Code Sniffer and PhpStorm

17:18 PHP Code Sniffer No response from /home/my_user/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs after 5000 ms Disable inspection Any idea? I've tried a lot of solutions like disable xdebug, increment response time. It…
Juan Wilde
  • 134
  • 1
  • 5
4
votes
2 answers

Storing results of phpcs fixer into a file

Is there any option to store the output of the phpcs fixer results into a file ? I tried the below phpcs --standard='Symfony' -a 'path' --report-file='~/Users/uname/Desktop/PHPcs' But it gives an error: ERROR: The specified report file path …
Jignesh Rawal
  • 521
  • 6
  • 17
4
votes
1 answer

What sniff needs to be used to enforce a camelCase variable naming convention?

I'm working on a proprietary legacy code base and some variables are camel-cased while others are snake-cased. I'd like to clean up and enforce only camel-cased variable names but I can't seem to find a sniff for that. Here are the contents of my…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
4
votes
1 answer

PHPMD and PHPCS Camelcase for Tests

I just installed both PHPMD and PHPCS with my Project. Now, I would like to customize them a bit, but can't seem to achieve it. I get 2 warnings that I would like to remove for all my project: phpcs: public method name…
Juliatzin
  • 18,455
  • 40
  • 166
  • 325
4
votes
1 answer

phpcbf complains about missing CodeSniffer

The Problem phpcbf complains about missing CodeSniffer but it appears to be missing from its own phar. My setup Ubuntu 14.04 using ondrej ppa for PHP 5.6 Here's what I've tried for installation and the output to verify installation sudo pear…
Matt
  • 5,315
  • 1
  • 30
  • 57
3
votes
3 answers

Referenced sniff "SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" does not exist

Just installed php_codesniffer and coder: composer global require "squizlabs/php_codesniffer=*" composer global require drupal/coder After installation, run phpcs -i and the result is as follows: The installed coding standards are MySource, PEAR,…
River Zhao
  • 73
  • 2
  • 8
1
2
3
13 14