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
2 answers

CodeSniffer sniff for generating dependency graphs for PHP code?

GOAL: I'm interested in generating a DOT Format description of the class dependencies in a PHP program. IDEA: It shouldn't be hard to write a CodeSniffer "sniff" that can detect (and emit DOT records for) the following patterns in PHP source: class…
Peter
  • 2,526
  • 1
  • 23
  • 32
5
votes
1 answer

Why should is_null() not be used?

Running CodeSniffer PHP style tests gave me the following error: The use of function is_null() is forbidden Squiz.PHP.ForbiddenFunctions.Found Why would use of is_null() be forbidden?
8128
  • 969
  • 1
  • 8
  • 27
5
votes
1 answer

PSR2 with class declarations extending classes with namespaces in PHP Code Sniffer

I've hit a problem with PHPCS using the PSR2 standard. Have searched high and low but to my surprise I can't find anyone reporting the same issue. Say I have a class declaration as follows:
oprimus
  • 396
  • 3
  • 11
5
votes
1 answer

Is there any way or workaround to have a perforce client-side trigger?

We don't have access to the server but we would like to run a code sniffer before submit the files to the depo. I know this is very simple having access to the server triggers but is there any possibility to have something like that in the client…
FranStrentz
  • 107
  • 6
4
votes
3 answers

Installing PHP PEAR code sniffer (mac)

Attempting to install the PHP PEAR code sniffer extension on a mac (after installing Mac Ports) to no avail. Ultimate goal is Drupal code sniffing in Komodo somewhat via these instructions...…
doublejosh
  • 5,548
  • 4
  • 39
  • 45
4
votes
1 answer

Unable to test Symfony2 console command

As part of learning Symfony2, I'm trying to write a very simple console command that simply runs phpcs (PHP Code Sniffer). Here's the execute function which is in a class extending ContainerAwareCommand: protected function execute(InputInterface…
josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157
4
votes
2 answers

Install PHP CodeSniffer with Netbeans 7.0.1 on Windows 7 64 bits

I'm trying to install PHP_CodeSniffer with Netbeans in my computer with Windows 7 64 bits. So far... 1) I've downloaded from https://github.com/beberlei/netbeans-php-enhancements/downloads the file de-whitewashing-php-cs-1.1.1.nbm, 2)installed the…
polonskyg
  • 4,269
  • 9
  • 41
  • 93
4
votes
1 answer

I am facing a PHP_CodeSniffer Error. Can you please help me?

One of our engineers facing an error with PhpStorm. Whenever he edits anything in PhpStorm, it gives the error related to PHP_Codesniffer: phpcs: env: php: No such file or directory... If open PHPCodeSniffer Inspection Settings, the below attached…
Joseph
  • 41
  • 1
  • 2
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

PHP_CodeSniffer missing Zend standards?

I'm trying to use PHP_CodeSniffer to sniff the problems in a php file according to the zend coding standards. The problem is some of the basic rules are not detected, for example String Literals $a = "Example String"; should give a warning because…
johnlemon
  • 20,761
  • 42
  • 119
  • 178
4
votes
2 answers

PHP codesniffer path to whole project

I`m new to this but i have installed composer and with it installed PHP Codesniffer. Now, how can i use php codesnifer to check for files in my entire project folder? My directory structure is something like this: ProjectName functions …
Cata John
  • 1,371
  • 11
  • 19
4
votes
0 answers

PHPCS Allow simple methods in one line

I find the code $ids = array_map(function ($entity) { return $entity->getId(); }, $entities); much more readable than $ids = array_map(function ($entity) { return $entity->getId(); }, $entities); However, the PHPCS forces me to use the…
fracz
  • 20,536
  • 18
  • 103
  • 149
4
votes
2 answers

PSR2 code style and PHP Code Sniffer doesn't agreed?

I have setup my editor code style setup from Editor > Code Style > PHP as Predefined Style >PSR1/PSR2. I have PHP Code Sniffer and PHP Mess Detector installed and configured as well. Any time I format the code using CTRL+ALT+L I get the following…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
4
votes
2 answers

Configure PHP CodeSniffer to fix code on the fly in PhpStorm

I have PhpStorm 10 and want to setup php Code Sniffer to automatically correct me code. This article https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm points to "Project Settings | Code Style" and I cannot even find…
Jack Smit
  • 3,093
  • 4
  • 30
  • 45
4
votes
2 answers

PHPCodeSniffer rule to limit the maximum number of instructions per function / method

I am looking for PHPCodeSniffer rule to limit the maximum number of code lines per function / method. function something($b) { // some comment that should be ignored in the count $a = 12; $value = sqrt( $a * $b ); …
AsTeR
  • 7,247
  • 14
  • 60
  • 99