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
4
votes
1 answer

Unclear Code Sniffer Errors

I have followed html markup with php code:
isOnline()): ?> Logout
When…
joni jones
  • 2,865
  • 3
  • 23
  • 28
4
votes
1 answer

PHP Code Sniffer not Picking up File, Class and Function Doc Comments

I'm working on implementing PHPCS into my build scripts and have resolved all ERROR and WARNINGS with relative ease (and a little help from SO :)). However, I cannot figure out why I'm still getting an ERROR saying the class is missing file, class…
Brian Bolli
  • 1,873
  • 1
  • 12
  • 14
4
votes
2 answers

Setup Yii 2 Web Framework Coding Standard in NetBeans

I read this and this. But how to setup this in NetBeans IDE in Windows machine?
Jomon Johnson
  • 154
  • 2
  • 7
4
votes
2 answers

Identify if a string is camelCase

I'm trying to get PHP_CodeSniffer to check for camelCase in class names, however it seems to me camelCase checking is impossible (without a dictionary, including techy words). I've raked the internet but so far the only options I've seen would be…
James
  • 4,644
  • 5
  • 37
  • 48
4
votes
1 answer

Tool to fix CodeSniffer issues in Wordpress plugin code

I have sniffed my plugin code using CodeSniffer with WordPress standard as mentioned at following link:- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards I got a ton of issues. Now I want to fix these with help of some tool…
Rajat Varlani
  • 456
  • 1
  • 4
  • 19
4
votes
1 answer

Why is PHP CodeSniffer Freezing?

I'm a Junior Programmer where I work. Our website was written using PHP 4. We're migrating from PHP 4 to PHP 5.3. There are roughly 5000 PHP files in around 595 directories. So, as you can imagine, the scope of this project is pretty huge. We use…
dqfan2012
  • 117
  • 10
4
votes
2 answers

CodeSniffer case indentation issue

I'm using Netbeans 7.1.1 with codesniffer. Whenever I have a case statement I get indentation errors, e.g. for the following code: switch ((int) $itemData['column_count']) { case 4: return 'grid-4columns'; case 6: …
Oleg Ishenko
  • 2,243
  • 1
  • 15
  • 16
4
votes
3 answers

How to compile php source code in PHP 5.4

I've been searching a way to compile PHP source code and using it in a PHP script by loading the compiled code. No resultat yet, a small try using bcompiler but it's not compiling due to changes on the Zend core API, maybe small parts need to be…
hgates
  • 209
  • 5
  • 12
4
votes
2 answers

How can I make PHP CodeSniffer Fixer ignore the namespace declaration?

I am using the sublime text 2 plugin for PHP Coding Standards Fixer. It is working fine, except for the fact that it considers the namespace invalid (it is in fact invalid and I'm okay with it). this errors halts the script from correcting the rest…
Rorchackh
  • 2,113
  • 5
  • 22
  • 38
3
votes
4 answers

PHPCodeSniffer HTML Report?

Does PHPCodeSniffer generates HTML Report? If not? How? Currently, I can run PHPCodeSniffer but it only produce XML file and displays result in the terminal. How can I make produce HTML Report like the coverage and unit test report in…
Annie B.
  • 275
  • 1
  • 6
  • 13
3
votes
2 answers

What are "MySource" and "Squiz" Coding Standards?

After installing Composer in windows 10, the result of phpc -i command is: "The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend." After lots of searches I was unable to find any documentation about MySource coding…
IT_man2018
  • 53
  • 7
3
votes
1 answer

How to exclude everything except some directories from PHP Code Sniffer inspections in .phpcs.xml?

I would like to exclude everything except some directories from PHP Code Sniffer inspection in my project. Something similar like git repo exclusions with .gitignore I had the idea that regex with negative lookahead could be used with…
kanlukasz
  • 1,103
  • 19
  • 34
3
votes
1 answer

Can all PHP mess-detecter checks be replaced with PHP code-sniffer checks?

I have a project which uses both PHPMD (PHP Mess Detector) and PHPCS (PHP Code Sniffer) which got me wondering if all PHPMD checks can be replaced with PHPCS checks or is it best to use both in tandem? The list of PHPMD checks seems to be here:…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
3
votes
1 answer

phpcs — Wordpress coding standard not working in Visual Studio

I get this error in visual studio: phpcs: The "WordPress" coding standard is not installed. Please review your configuration an try again. In settings.json: "php.suggest.basic": true, "php.validate.run": "onSave", …
Jamie
  • 1,909
  • 3
  • 22
  • 47
3
votes
1 answer

PHP CodeSniffer Error: The phpcs report contains invalid json

I want to add PHP CodeSniffer to VScode. Within VScode I am getting the error 'phpcs: The phpcs report contains invalid json' However when I run the following command in the terminal: phpcs --standard="WordPress-Core" -q --report=json…
Michelle M.
  • 515
  • 1
  • 7
  • 20