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
13
votes
4 answers

Use PHP_CodeSniffer for modified lines only

I am trying to build a pre-commit script in SVN, and I want to run PHP_CodeSniffer on the modified lines only (as opposed to the whole file). So far I have this script: #!/bin/sh REPOS="$1" TXN="$2" # Make sure that the log message contains some…
Antonio
  • 381
  • 4
  • 12
12
votes
3 answers

How to add multiple paths for phpcs?

I want to configure multiple installed paths for phpcs. I can add one via: phpcs --config-set installed_paths the/dir/to/standard I tried adding multiple by using : yet it did not work and the man page is non-existent and the help not that helpful.
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
11
votes
1 answer

How can I set my preferred indent level with PHP CodeSniffer?

I don't want to ignore the indent level. I want to enforce a particular indent level that is not the default, 4. Apparently this is possible: How? The documentation on this stuff seems to be eluding me.
Cheeso
  • 189,189
  • 101
  • 473
  • 713
11
votes
1 answer

@param tag alignment in php code sniffer

I am using php code sniffer for a function, i want to add @param tag but it is giving me alignment error of first and second param. /** * for generating thumbnail * * @param int $minSize an integer to size of thumbnail * @param string…
XMen
  • 29,384
  • 41
  • 99
  • 151
11
votes
1 answer

PHPStorm Is throwing an error when trying to run phpcs

I am trying to run the PHP CodeSniffer, but I get an error. PHP Code Sniffer phpcs: Can not correctly run the tool with parameters: C:/Users/me/AppData/Local/Temp/___0.tmp/Foo.class.php --standard=PSR2 --encoding=utf-8 --report=xml Possible tool…
nobrandheroes
  • 748
  • 1
  • 10
  • 17
11
votes
1 answer

What is the right way to install codesniffer to Aptana Studio standalone version?

I followed this guide for eclipse integration on drupal: https://drupal.org/node/1420004 I tried to install PTI plugin to Aptana (Aptana Studio 3, build: 3.4.1.201306062137, with Eclipse Platform Version:…
Phoenix
  • 756
  • 1
  • 7
  • 22
11
votes
3 answers

Custom ruleset for phpcs using PHPStorm

I'm trying to somehow convince the phpcs to use the Zend coding guidelines, -but- to allow me to have variables with underscores (like $blub->foo_bar). Could anyone tell me how to change the ruleset that phpcs uses from within PHPStorm, please?
user1293263
  • 131
  • 1
  • 2
  • 5
10
votes
2 answers

Ignore specific warnings with PHP_CodeSniffer

I am working on a password tools module, and part of it is using base64 Encoding/Decoding. As a result I have a number of variables which include the term 'base64' for obvious reasons. The problem is that when I run the PHP_CodeSniffer tool, it…
Stephen RC
  • 1,494
  • 2
  • 19
  • 34
10
votes
10 answers

PhpStorm Can not run PHP Code CodeSniffer

Im trying to use CodeSniffer in PhpStorm. In settings->PHP->CLI Interpreter I linked to the php.exe Im using https://windows.php.net/ but also tried it with Cygwin and XAMPP. PhpStorm shows me the right PHP Version 7.2.5 and the php.ini In the…
Ted Logan
  • 404
  • 1
  • 4
  • 15
10
votes
1 answer

Exclude a specific PHPCS rule for a specific file

We're using PSR0, PSR1 and PSR2 standards in our project, but I want to exclude a specific file from just the PSR0 namespace checking rule. Is there a way I can add a comment to the file, so phpcs ignores this rule: Each class must be in a namespace…
josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157
9
votes
1 answer

How to use CodeSniffer in Netbeans 8.1

I have installed Netbeans 8.1 and Xampp for Windows with PHP 5.6. Netbeans 8.1 has the CodeSniffer installed by default. Xampp too (pear). And Netbeans detects the "standars": But now, I don't know how to run CodeSniffer in my php files. There is…
JoniJnm
  • 720
  • 2
  • 10
  • 19
9
votes
2 answers

What is the error generated by phpcodesniffer "Tag cannot be grouped with parameter tags in a doc comment"

/** * @param Varien_Event_Observer $observer eventobserver * @return void */ phpCodesniffer generate the following error for the above line. 41 | ERROR | Tag cannot be grouped with parameter tags in a doc comment. What will be the reason?
Febin Thomas
  • 371
  • 2
  • 8
9
votes
1 answer

Opening parenthesis of a multi-line function call must be the last content on the line

I Write this code in my PHP file : public function ScriptsStyles() { wp_enqueue_style( 'fontawesome', plugins_url("/css/font-awesome.css", __FILE__), array(), 'null' ); …
2dar
  • 611
  • 2
  • 9
  • 22
9
votes
3 answers

Wrong include_path for Codesniffer

This issue has been addressed before and I have tried to solutions offered and think I am doing something wrong. I am attempting to configure PHP Codesniffer on a Mac using Mountaion Lion. I don't think it matters, but I ma using XAMMP. I am…
user1342600
  • 101
  • 1
  • 2
8
votes
2 answers

SVN Pre-commit hook to be triggered for a particular folder

One of our client's SVN repository has quite a bunch of projects under the single repository. Now I want to check coding-standard for one of the project via pre-commit hook. If I configure the pre-commit, it is going to affect all the projects…
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66
1
2
3
21 22