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

PHPCS / PHPMD : Is there a PHP Code Sniffer / Mess Detector way to ensure there are docblocks?

Is there a way I can use PHP Code Sniffer and/or PHP Mess Detector to detect if my classes/properties/methods have proper docblocks? For example: class Foo { protected $bar; public function doStuff(){ // ... } } The above…
Giel Berkers
  • 2,852
  • 3
  • 39
  • 58
1
vote
1 answer

phpcs error references old project path -- how do I update the path?

When I run phpcs, it prints an error that references the path where my project formerly was located, but is no longer located... PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message…
arnoldbird
  • 886
  • 1
  • 13
  • 30
1
vote
1 answer

Configuration PHPcs in Sublime 3

I have copy paste the default phpcs.sublime-settings to User and set phpcs_execute_on_save to true but it does not work. it shows me an error Exception in thread Thread-9: Traceback (most recent call last): File "./python3.3/subprocess.py", line…
hu7sy
  • 983
  • 1
  • 13
  • 47
1
vote
0 answers

wp-admin/includes/class-pclzip.php error set_magic_quotes_runtime() removed since PHP 7.0

I've checked my code compatibility with PHP 7 using PHP Code Sniffer, PHPCompatibility and I got the error bellow. [1mFILE:…
natali
  • 125
  • 2
  • 9
1
vote
0 answers

How to get more error information from phpcbf (phpcs)?

I have a php file that I ran through phpcs. It completed successfully and reported that phpcbf could fix 1199 issues. However, when I run phpcbf, it errors out with no explanation at what looks like the end of the process. If I delete about half of…
user1404617
  • 585
  • 1
  • 5
  • 20
1
vote
0 answers

Making PHPCS understand square brackets as array initializer on eclipse

I'm using Eclipse Mars.1 with the latest version of PDT and the latest PHPCS. I'm using a variant of the PEAR formatter on my PHPCS and there is one behaviour that is annoying as hell. It does not understand the identation of a square bracket as…
Yohan Leafheart
  • 860
  • 1
  • 11
  • 27
1
vote
1 answer

Is there a tool to analyze PHP code to check whether returned value is used properly?

Let's say I have the following code: $result = $thirdPartyAPI->doSomething(); // returns false if error if ($result == false) { return $someErrorCode; } // process the valid $result I have lots of calls to the $thirdPartyAPI spread throughout…
rchavarria
  • 930
  • 10
  • 16
1
vote
1 answer

PHPCS result parsing stopped working in NetBeans 8.0.2 (Inspector: Unknown items)

I have NetBeans 8.0.2 on Linux Mint 17.2 Rafaela x86_64. Installed this PHP Code Sniffer: PHP_CodeSniffer version 2.3.4 (stable) by Squiz (http://www.squiz.net) The results used to be parsed fine in NetBeans for a while so that they were…
Cigydd
  • 93
  • 1
  • 8
1
vote
1 answer

where does phpcs store values on windows os

I am able to do successfully the command phpcs --config-set show_progress 1 but I don't know where phpcs stores this values on my disk on Windows 7 Operating System.
1
vote
0 answers

Using Codesniffer with netbeans for CakePHP

I am using netbeans 8 and CakePHP 2.x. I have installed using composer inside my vendors folder the codesniffer for CakePHP. Then from terminal I run the command: vendors/bin/phpcs --config-set installed_paths…
gmponos
  • 2,157
  • 4
  • 22
  • 33
0
votes
0 answers

How can I prevent phpcs from scanning docblock / comments?

I am using (among others) the following PHPCS sniff: Squiz.WhiteSpace.SuperfluousWhitespace.EndLine But I find it frustrating that end-of-line white space within docblocks is getting flagged. Is there any way to disable the errors specifically for…
JakeParis
  • 11,056
  • 3
  • 42
  • 65
0
votes
1 answer

Cannot install friendsofphp/php-cs-fixer on Symfony 5.4 and PHP 8.2

I'm on a symfony 5.4 installation with PHP 8.2 and I'm trying to require friendsofphp/php-cs-fixer with composer require friendsofphp/php-cs-fixer -W --dev Unfortunately I'm getting the following conflicts but I can't see the exact steps I need to…
Wolf-Tech
  • 1,259
  • 3
  • 18
  • 38
0
votes
0 answers

Liniting deprecated wp function over version 4.9.0 phpcs vscode

in my current project i'm using the following configuration composer.json: "require-dev": { "php": "^7.4 || ^8.0", "dealerdirect/phpcodesniffer-composer-installer": "1.0.0", "phpcompatibility/php-compatibility": "^9.3.5", …
user1956396
  • 55
  • 1
  • 9
0
votes
1 answer

Laravel Pint formatting issue with line breaks in comments

I'm using Laravel Pint for code styling in my Laravel project. I have a function with a multi-line comment block that includes various tags such as @description, @author, and @email. When I run Laravel Pint to format my code, the comment block gets…
Arafath
  • 1,090
  • 3
  • 14
  • 28
0
votes
0 answers

How to introduce a lint in bitbucket pipeline in an old repository?

I have some repositories where I want to install a lint. My main concern here is that it's a lot of old code that would certainly not pass, and fixing everything is simply not a viable options. So I only want to use the lint on new code. And I found…
klutt
  • 30,332
  • 17
  • 55
  • 95