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

How to configure php_codesniffer to force the PHP 7.4 property type declaration?

I'd like to configure my phpcs ruleset so it would force the PHP 7.4 added type declaration for class properties. Currently I'm using the PSR-12 standard ruleset and I want to add there a sniff, which will scan this code: /** @var string…
Jiří Kolda
  • 53
  • 1
  • 8
2
votes
2 answers

Is there a rule for enforcing strict comparison (===) using PHP Code Sniffer?

As title says. I am looking for a rule similar to eslint's eqeqeq, but for PHP. I would want to enforce the use of ===/!== instead of ==/!=. I have tried googling and searched through their repo as well, but unfortunately to no avail. Just wanna ask…
carestad
  • 3,196
  • 2
  • 13
  • 10
2
votes
1 answer

phpcs WordPress ruleset error Detected usage of a non-sanitized input variable: $_FILES

I have a function of a file uploading. While uploading a file when I run the PHP_CodeSniffer phpcs I am getting the error. I am running WordPress ruleset. Detected usage of a non-sanitized input variable: $_FILES $fext = $file =…
2
votes
1 answer

Inspect Subdirectories of an Excluded Folder with PHP CodeSniffer

I am attempting to configure my phpcs.xml (PHP CodeSniffer configuration file) so that I can exclude all directories from inspection within a folder except for those that I specify. For those familiar with .gitignore, an equivalent would be…
Phil Birnie
  • 1,104
  • 2
  • 12
  • 29
2
votes
4 answers

installing CakePhp: "Your requirements could not be resolved to an installable set of packages" error

I'm trying to install cakephp using composer with this tutorial but after I run the command: sudo composer create-project --prefer-dist cakephp/app my_app_name I get the error: Problem 1 - cakephp/cakephp-codesniffer 3.0.0 requires…
Bahman Rouhani
  • 1,139
  • 2
  • 14
  • 33
2
votes
2 answers

Trouble installing PHP Code Sniffer

I'm attempting to install PHP Code Sniffer for PhpStorm, but have been unable to get it to work. I've been following the steps here: https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm I added PHP Code Sniffer as a…
Titan9251
  • 35
  • 1
  • 6
2
votes
1 answer

Force space indentation instead of tabs in PHP_CodeSniffer?

In my custom sniff I added Which works for functions and…
dingo_d
  • 11,160
  • 11
  • 73
  • 132
2
votes
2 answers

Error with ternary operator in PHP code sniffer

I have problem with PHP code sniffer and ternary operator. I added rule for checking spaces after and before operators and now I have errors in short if statements: 37 | ERROR | [x] Expected 1 space…
jager91
  • 272
  • 6
  • 15
2
votes
1 answer

PhpStorm show CodeSniffer annoying message when install Xdebug

After install Xdebug on PhpStorm, CodeSniffer start show this annoying balloon message: phpcs: Can not correctly run the tool with parameters: /tmp/phpcs_temp.tmp/app/Http/Controllers/PostController.php --encoding=utf-8…
Odin Thunder
  • 3,284
  • 2
  • 28
  • 47
2
votes
1 answer

What is the best place for tools like phpcpd, phpmd, php_codesniffer

What is the best place for tools like phpcpd, phpmd, php_codesniffer to include them in composer require-dev section or install as phar archive somewhere in the system? When they are included in require-dev often it is not possible to update for…
klipach
  • 818
  • 7
  • 21
2
votes
0 answers

phpcs reported errors with note phpcbf can fix these marked errors but phpcbf claimed no fixable errors found

.../vendor/squizlabs/php_codesniffer/phpcs --standard=PSR2 myfile.php The report is FOUND 10 ERRORS AND 5 WARNINGS AFFECTING 15 LINES ... 236 | ERROR | [x] Line indented incorrectly; expected 4 spaces, ... PHPCBF CAN FIX THE 10 MARKED SNIFF…
searain
  • 3,143
  • 6
  • 28
  • 60
2
votes
1 answer

Docker CodeSniffer - phpcbf doesn't change files

Hello i have a problem with phpcbf. Here is my docker configuration: docker-compose.yml version: "2" services: data: build: docker/application volumes: - .:/var/www/html fpm: build: docker/php-fpm …
Jack
  • 93
  • 11
2
votes
1 answer

Allow lack of space after function parenthesis if there is a return type hint in PHP (CodeSniffer)

I am using the MediaWiki coding standard for php_codesniffer. Thing is, that is created for PHP version <7.0.0. Let's take the following not-formatted code snippet: function test(){} The sniffer will report an error, that is needs space between )…
Victor
  • 13,914
  • 19
  • 78
  • 147
2
votes
1 answer

PHP Code Sniffer via Grunt is incredibly slow

I'm having issues with PHP Code Sniffer running inside of a Grunt task. Everything has been freshly installed. PHP CS runs perfectly from the terminal (run in less than 2 secondes). But when I run it thought a Grunt task (same binaries, config file,…
2
votes
1 answer

Can't remove old PHP_CodeSniffer install

My employer has asked me to move from a PEAR phpcs install to a global Composer phpcs install. In trying to make that change, I've discovered an existing phpcs of an old version. macpro@~ $: which phpcs /usr/local/bin/phpcs macpro@~ $:…
Lou Groshek
  • 718
  • 6
  • 23