Questions tagged [phpcs]

A component of Php Code Sniffer Package, phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.

Useful links:

203 questions
1
vote
2 answers

SublimeText and php-cs errors

I install SublimeLinter and PHP-cs with PHP-cs Fixer and I'm getting some warning and some errors, but I want to ignore them. 2:1 error phpcs: error Missing file doc comment 11:1 error phpcs: error Missing doc…
Carloscito
  • 373
  • 1
  • 2
  • 16
1
vote
0 answers

PhpStorm reformat differs from phpcs (Zend CodeStyle)

I have configured my PhpStorm to use Zend for Code Style PhpStorm | Preferences | Editor | Code Style | PHP | Set from Zend The result for PhpStorm reformat looks like this: '/img', …
Confidence
  • 2,283
  • 3
  • 33
  • 57
1
vote
0 answers

Issue with Code Sniffer on Ubuntu 16 - Install pfff

I am trying to setup PHPCS, PHPMD on my Ubuntu 16.04 I was following these instruction but I am getting stuck at Installing pfff which phpcs -/usr/bin/phpcs which phpcbf -/usr/bin/phpcbf which php-cs-fixer -/usr/local/bin/php-cs-fixer which…
1
vote
1 answer

Permission denied in Bitbucket pipeline

I am having trouble getting a bitbucket pipeline to run correctly, it keeps throwing a permission denied error and I can't for the life of me see why? This is my composer file: { "name": "pswebsolutionsltd/psadoptables", "description": "Framework…
1
vote
1 answer

PHPCS exit code based on threshold

Im trying to implement PHPCS in my project which has an huge technical depth. I have for example one module with 378 sniffs (both errors and warnings combined). However the fact is that i also have like 29 modules which makes it nearly impossible to…
Dirkos
  • 488
  • 1
  • 10
  • 33
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

How to load multiple coding standards in phpcs

How could load multiple coding standards in phpcs? While sniffing the files, I am supposed to use an xml file which uses three coding standards. When I try to set their paths one by one, only recent one gets stored and old standard gets…
Shantanu Deshpande
  • 185
  • 1
  • 1
  • 11
1
vote
1 answer

adding fixable errors using phpcs

When I call addFixableError in phpcs the output shows a fixable error as expected, however in the sniff code I check the return and this is false and I would therefore expect the output from phpcs to show that the error is not fixable. I am correct…
GrahamL
  • 243
  • 2
  • 15
1
vote
1 answer

How to specify custom standard with bruli/php-git-hooks library

I am using this PHP Library here https://github.com/bruli/php-git-hooks, this library uses phpcs (https://github.com/squizlabs/PHP_CodeSniffer) I have a php-git-hooks.yml config file like this pre-commit: enabled: true execute: phpcs: …
Sam Anthony
  • 1,669
  • 2
  • 22
  • 39
1
vote
0 answers

"phpcs -i" does not return any results

I've installed PHPCS via pear, and all the instructions say that if everything goes right running PHPCS -i should return something. But they never say what to do when it doesn't work. This was working a few months ago, and now does not.…
Picard102
  • 624
  • 1
  • 9
  • 21
1
vote
1 answer

Configuring phpcs to disallow spaces after closing bracket and before closing bracket

Most of our projects are WordPress, and while we agree with the most of coding standards it sets, there are some which we disagree on and do not want to use in our own private projects. Somehow pieces of those disagreements still end up in the…
Christian
  • 927
  • 2
  • 13
  • 22
1
vote
1 answer

How do PEAR class comment and file comment sniffs cooperate?

The PEAR standard has File and Class comment code sniffs and I am uncertain as to how they interact. The first part of the PEAR class comment check is $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); if…
GrahamL
  • 243
  • 2
  • 15
1
vote
0 answers

Is it possible to force everyone to comment their code using PhpStorm settings or phpcs?

We're a team of 4 people ready to start working on a project and I want to know if is there a way to force everyone to comment every function, class or big chunk of code that they write before pushing into the repository. I was thinking if I can…
Jack Dox
  • 21
  • 1
1
vote
1 answer

how to set custom rule for unused variable and method in php code sinffer?

I am using php code sniffer with smyfony 3.1. Package Name:Squiz I am trying to run phpcs command in my symfony based project. Command: phpcs --standard=/c/xampp/php/pear/PHP/CodeSniffer/Standards/Squiz src/MYBundle/Controller/MYController.php …
Ashish Kumar Saxena
  • 4,400
  • 8
  • 27
  • 48
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…