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
3
votes
3 answers

Sublime Text 3 Phpcs not working on Windows7

I have installed PHPCS using @install package in my Sublime Text3 . I can see Tools->PHP Code Sniffer:Sniff this file command, but when i select 'Sniff this file' command nothing happens. Here is my Prefrences->Package Settings->PHP Code…
deepika jain
  • 363
  • 3
  • 7
3
votes
1 answer

How to ignore some validations on PHP Code Sniffer on Eclipse?

I started using the PHP Code Sniffer extension for Eclipse (Kepler SR1 Build id: 20130919-0819) but I'm running in an usability issue. Due to the way code sniffer works on eclipse, it marks a file that has an error with the same icon as file that…
Yohan Leafheart
  • 860
  • 1
  • 11
  • 27
3
votes
1 answer

PHPMD - Avoid using Static Access to class - Using a constant?

I am using PHP Mess Detector 1.5.0 and have a number of issues, that I do not believe are issues. class FOO { const NEW_LINE = "\n"; const ADD = 1; const DELETE = 2; ... public function __construct($OptionOne = self::ADD) { …
Steven Scott
  • 10,234
  • 9
  • 69
  • 117
3
votes
2 answers

Using Jenkins and Php Code Sniffer

I'm trying to use the Php Code Sniffer plugin in Jenkins. It generates a checkstyle.xml file but there are no errors inside, and I know that I should have. Here's the containt of my checkstyle.xml :
Stephtheboss
  • 65
  • 1
  • 1
  • 6
3
votes
1 answer

codesniffer command not being recognized after several installs and upgrades

I've tried to install codesniffer using pear but my mac is not recognizing the phpcs command. pear config Configuration (channel pear.php.net): ===================================== Auto-discover new Channels auto_discover 1 Default Channel …
numerical25
  • 10,524
  • 36
  • 130
  • 209
3
votes
2 answers

Command line tool to apply suggestions provided by PHP Codesniffer

I am looking for a command line tool that applies code formatting suggestions provided by PHP codesniffer into my code base. There are some cool tools like PHP CodeSniffer plugin to Eclipse but in my use case I need to do this as a batch process…
3
votes
2 answers

How to get all the keys for of a PHP Codesniffer Ruleset to use with Sonar?

I am trying to add the Drupal Coding standards in phpcs. I can run the Drupal Standards with phpcs --standard=Drupal Now I want to execute the same standards with Sonar. In Sonar I can add the keys of all the rulesets in the rules.xml extension,…
Bhavin Vora
  • 451
  • 3
  • 12
3
votes
2 answers

Style check PHP Progressively (Incrementally)

I like automated checks on my codebase to make sure I'm not violating style guidelines. When I worked in Perl, I would use Perl::Critic to check my style, and Test::Perl::Critic::Progressive to grandfather in any existing violations, so I could…
Sean McMillan
  • 10,058
  • 6
  • 55
  • 65
2
votes
1 answer

Where to place downloaded PHP_CodeSniffer?

I want to download and install PHP CodeSniffer On the website is mentioned that it can be installed manually. There is not mentioned, where I should place downloaded folder. Is there any standard where I should place such PHP scripts from PEAR…
tomas.teicher
  • 913
  • 3
  • 13
  • 26
2
votes
1 answer

Code sniffer, How to validate just clear PSR2?

my configuration: phpcs --config-set default_standard PSR2 ./../../web
user2219071
  • 113
  • 10
2
votes
2 answers

token_get_all() returns different values on same php version

I'm using PhpCS to detect wrong syntax in my code. This tool use the function token_get_all however I have some inconsistency between PHP version (or even the same PHP version online) The simplified code is : var_dump( token_get_all('') …
MaryShaw
  • 128
  • 4
2
votes
0 answers

PhpStorm code style and PHP_CodeSniffer conflict: Multi-line function call not indented correctly; expected 12 spaces but found 16

I am using PHP_CodeSniffer like this to scan my code: vendor/bin/phpcs --standard=PSR12 src I also configured PhpStorm to use PSR-12 at Preferences -> Editor -> Code Style -> Set From -> PSR12 When I run PHP_CodeSniffer there are no error at first,…
Gregory Boutte
  • 584
  • 6
  • 26
2
votes
1 answer

Is there any Customizable Sniff Properties for classes/traits/interfaces?

is there any Customizable Sniff Properties for classes/traits/interfaces to do the followings; not allow a blank line before the first content One blank line after the last content I am expecting a rule for something like this. example Valid…
Safry
  • 191
  • 1
  • 9
2
votes
0 answers

Magento install on MacOs: Failed to set PHP CodeSniffer installed_paths Config

I was trying to install Magento 2 on MacOS 10.15 using https://alpineinc.com/2020/05/install-magento-2-locally-on-a-mac/. I use the command: php composer.phar create-project --repository-url=https://repo.magento.com/…
phhhy
  • 67
  • 1
  • 9
2
votes
1 answer

phpcs: Referenced sniff "PHPCompatibility.PHP.RemovedExtensions" does not exist

I am trying to install PHP CodeSniffer with WordPress Coding standards on VSCode Windows. I got the PHP Code Beautifier and Fixer to work however the errors are not highlighted and an error appears saying "phpcs: Referenced sniff…
Jafar Salami
  • 321
  • 4
  • 18