Questions tagged [phpcodesniffer]

PHP_CodeSniffer is a PHP PEAR package that can be used to tokenise PHP, JavaScript and CSS files and to detect violations of a defined set of coding standards.

PHP_CodeSniffer is a PHP PEAR package that can be used to tokenise PHP, JavaScript and CSS files and to detect violations of a defined set of coding standards. More information can be found here: http://pear.php.net/package/PHP_CodeSniffer/redirected , including documentation and download links.

327 questions
5
votes
1 answer

How to setup PHP CodeSniffer that extend WordPress coding standards + autofix errors in VSCode?

How to setup PHP CodeSniffer for project with personal rules that extend WordPress coding standards + autofix errors in VSCode on save? I have installed CodeSniffer globally composer global require "squizlabs/php_codesniffer=*" WordPress coding…
Ivan Topić
  • 3,064
  • 6
  • 34
  • 47
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

PHP CodeSniffer WordPress via Composer

Is there a way to install PHPCodeSniffer and WordPress Coding Standards for PHP_CodeSniffer per project via Composer? I've installed both as dev dependencies and set the installed path to WordPress Coding Standards in CodeSniffer.conf. Unfortunately…
marcobiedermann
  • 4,317
  • 3
  • 24
  • 37
5
votes
4 answers

How can PHP CodeSniffer check files that have no extension?

In my team we are using codesniffer to enforce a coding style for a Symfony application, and just realized that the files without extension are not getting checked, even if we explicitly use the file as an argument. This is by design as discussed on…
Loupax
  • 4,728
  • 6
  • 41
  • 68
5
votes
1 answer

What rule prevents empty lines after the class opening brace?

I'm looking for a rule that prevents empty lines after the opening brace of a class. I found the rule Squiz.WhiteSpace.FunctionOpeningBraceSpace for functions, but I can't find any for classes. Any suggestions are appreciated.
Milad
  • 115
  • 1
  • 1
  • 11
5
votes
2 answers

Any way to show only error on codesniffer

I want to see only error in codesniffer. Because file have too many warning and i have only correct the errors. Can any know how to to do that?
Qaisar Satti
  • 2,742
  • 2
  • 18
  • 36
5
votes
1 answer

Is there any Symfony CodeSniffer ruleset

I've been trying to use PHP_CodeSniffer on Symfony projects but it usually throws warnings that are not usually follow by the Symfony community (Like commenting parameter tags or not grouping parameters and returns in function docs) I was wondering…
user1335895
5
votes
1 answer

PHP Codesniffer custom rule: constant ::class instead of string

In the codebase of one of my clients I see a lot of references to a qualified class name as a string; [ 'foobar' => 'My\Namespace\Class' ] Instead of using: [ 'foobar' => My\Namespace\Class::class ] For a couple of reasons we want to add a…
Arjan
  • 416
  • 2
  • 4
5
votes
2 answers

php codesniffer returns nothing ... is my code in standard?

I have a laravel application (created with composer) that I am trying to ensure meets PHP coding standards (level PSR-1). I run: $ phpcs --standard=PSR1 my_app/ And within a few seconds it returns with just a new, empty, ready-to-go command…
Laura_E
  • 169
  • 1
  • 10
5
votes
1 answer

How to use PHP_CodeSniffer with XAMPP?

I am running XAMPP with windows XP. I just download PHP_CodeSniffer and cannot figure out how to run it. Thank you
q0987
  • 34,938
  • 69
  • 242
  • 387
5
votes
1 answer

Getting error in PHP CodeSniffer

When I try to open a file in PHPStorm(10.0.3) getting following message. phpcs: PHP Fatal error: Call to undefined method PHP_CodeSniffer_File::recordMetric() in /usr/share/php/PHP/CodeSniffer/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php on line…
KKK
  • 1,652
  • 7
  • 29
  • 49
5
votes
3 answers

How to use PHPCBF to fix one issue at a time?

I've added a PHPCS configuration to get some standards into a legacy project. I'm using a relaxed version of PSR-2 as an interim step. Now what I want to do, is slowly remove the exclusions, one by one, committing the changes into Git each step of…
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
5
votes
1 answer

PSR-2 CodeSniffer standard for eclipse plugin PHP_CodeSniffer

I'm using this eclipse plugin (http://www.phpsrc.org/projects/pti-php-codesniffer/wiki/) to check PHP code style. This plugin comes with some standards to check, but no with PSR-2. This plugin lets define a custom standard by giving a file. I've…
Jordi Martínez
  • 358
  • 3
  • 14
5
votes
1 answer

What's the difference between sublimelinter-php and sublimelinter-phpcs?

From what I know, CodeSniffer follows a certain set of coding standards and checks your code if it follows the said standards. But sublimelinter-php does this too. Are they different or are they just the same? Because I installed both plugins on my…
Gannicus
  • 530
  • 1
  • 7
  • 26
5
votes
1 answer

Modifying PEAR standard for phpcs

I'd like to make a small change to the PEAR standard for our phpcs validation. At the moment PEAR requires you to write else statements like this: } else { We'd like to write them like this: } else { How can I go about making this change?
Noodles
  • 900
  • 4
  • 14
  • 30