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
1
vote
1 answer

git pre-commit hook under Windows run PHP_CodeSniffer against staged files

I try to use CodeSniffer in combination with a pre-commit git hook. I can run phpcs --standard=PSR2 PhpFile.php so the installation of CodeSniffer seems to work fine. I try to use this piece of code as premade git hook. However I'm pretty sure this…
online Thomas
  • 8,864
  • 6
  • 44
  • 85
1
vote
1 answer

How to set PHPTools preferences in Eclipse 4.7.2?

I recently reinstalled my system and Eclipse PDT, now I'm faced with the following problem. I seem unable to open the workspace preferences for CodeSniffer. Via Window / Preferences / PHP Tools / PHP CodeSniffer, I get two error messages: - "Could…
1
vote
1 answer

why this error is coming in php cs

I am running this phpcs command to check one file . I am getting this error. ubuntu@myip:/var/www/ryapi$ phpcs -n content.php PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line…
XMen
  • 29,384
  • 41
  • 99
  • 151
1
vote
2 answers

is there an API for PHP_CodeSniffer?

Does PHP_CodeSniffer have an API I can use, rather than run the command line? So given a string of PHP code, $code, and Composer ensuring loading of the PHP_CodeSniffer code, is there something I can do such as: // Pseudocode! $code_sniffer = new…
joachim
  • 28,554
  • 13
  • 41
  • 44
1
vote
3 answers

How to combine arrays and show in one table

I have three JSON arrays Now I have decoded(json_decode) to convert it into PHP associative arrays in the result it's showing this result. Now I want to show this three array in one table like this. How can I do that please help.
Salman Iqbal
  • 442
  • 5
  • 23
1
vote
1 answer

Pear and PHP_CodeSniffer installation issues: not able to use phpcs from command line

My setup: Mac OSX El Capitan 10.11.6, PHP 7.0.24-1+ubuntu14.04.1, PEAR Version: 1.10.5, I'm working on a local wordpress build using vagrant/virtualbox (vvv). I'm new to pear and php_codesniffer and cannot seem to get phpcs commands to work. I've…
carlarenee
  • 19
  • 3
1
vote
1 answer

How to fix, assignments must be the first block of code on a line?

I'm developing WordPress plugin and stuck with code sniffer warnings. How do I fix the below warning message? [Squiz.PHP.DisallowMultipleAssignments.Found] Assignments must be the first block of code on a line The above error/ warning is…
Maqk
  • 515
  • 9
  • 26
1
vote
1 answer

php codesniffer + xampp: Missing PEAR/Exception.php

I followed exactly what's in: How to use PHP_CodeSniffer with XAMPP? (no more no less) But i encounter this error: Warning: require_once(PEAR/Exception.php): failed to open stream: No such file or directory in…
gianebao
  • 17,718
  • 3
  • 31
  • 40
1
vote
0 answers

How to solve The opening PHP tag must be the first content in the file coding standard error

Error . The opening PHP tag must be the first content in the file My file code FOUND 1 ERROR AFFECTING 1 LINE code here
Qaisar Satti
  • 2,742
  • 2
  • 18
  • 36
1
vote
2 answers

How to create multiple USE statements in sniff

I'm working on a sniff for PHP_CodeSniffer 3.x. For example, the class declaration class NoInlineFullyQualifiedClassNameUnitTestInc extends \PSR2R\Base\AbstractBase should be split into a uses and class AbstractBase. The sniff detects similar issues…
Edward Barnard
  • 346
  • 3
  • 17
1
vote
1 answer

Code sniffer for for converting snake_case to camelCase

I need a code sniffer for converting all the variables in all of my PHP file from snake_case to camelCase. I don't need the functions which do it in php on a string, I want to convert the variables in my PHP files to camelCase. I appreciate you in…
Malus Jan
  • 1,860
  • 2
  • 22
  • 26
1
vote
1 answer

Is there some way to integerate cruisecontrol and jenkins

I require php extension of cruisecontrol which I want to use for code quality analysis upon jenkins build. How can I achieve this? If in case this cannot be achieved then what can be other possible way by which I can carry code quality analysis…
YATIN GUPTA
  • 916
  • 9
  • 17
1
vote
1 answer

'Syntax error near unexpected token' error on PHP code sniffer .xml file without a syntax error in it

phpcs is installed on the system and code sniffing works fine from the command line. phpcs --extensions=php /path/to/code.php` ^ works fine. For the PHP Storm IDE, I've specified the location of the ruleset.xml file in the settings like so: Cmd +…
Ketcomp
  • 434
  • 6
  • 20
1
vote
1 answer

phpcs errors on Linux Mint

I have installed composer and phpcs on Linux Mint, after running the command in terminal phpcs --standard=WordPress-VIP class-wpeka-auto-updater.php it throws the following errors PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: Referenced…