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
2 answers

PHP Code Sniffer and camel caps

I have just started to use Code Sniffer to clean up my code. I found out that Code Sniffer catches php's built-in function names as errors. For example: on line if($mysqli->connect_error === true) { I get a message that: Variable "connect_error" is…
bolshas
  • 101
  • 3
  • 15
2
votes
1 answer

How to improve PHP CodeSniffer execution time?

Although it is important to be able to optimize individual "sniff" implementations, my question isn't really about that. What I really want to do is run my favorite dozen-or-so sniffs over my entire codebase (which contains several million lines of…
Peter
  • 2,526
  • 1
  • 23
  • 32
2
votes
1 answer

PHP_CodeSniffer Many Classes per file sniff

We have a standard in use, where we create exceptions within the main class for returning errors etc... The problem is, that all the standard sniffs do not like this. We are writing our own sniffs then for this, but thought I would inquire why…
Steven Scott
  • 10,234
  • 9
  • 69
  • 117
2
votes
1 answer

Using Pear's PHP codesniffer with MAMP Pro on mac

I’d like to ask for some help getting Pear’s PHP Code Sniffer set up properly. I’m using MAMP pro 2.0.5 on a Mac PB 10.7.4 with PHP 5.3.6. I do have Pear installed and can run pear commands, when I installed the PHP_CodeSniffer channel I didn’t get…
StephanieF
  • 1,211
  • 1
  • 11
  • 19
1
vote
1 answer

Codesniffer gives multiple Indent Space errors for same line

I seem to be getting a strange situation where CodeSniffer is applying 2 indent space conditions on some lines of code. An example is below, where, if I set 0 indent on the line for demo purposes, it outputs the following error: 336 | ERROR | Line…
jasonmcclurg
  • 196
  • 8
1
vote
1 answer

How to manually insert error in Checkstyle?

I'm trying to do something that might seem strange but that makes sense. I would like to manually trigger a violation in Checkstyle from within in my code. Let's say I'm working on a project where all code is written in french. (Yes, I'm french).…
i.am.michiel
  • 10,281
  • 7
  • 50
  • 86
1
vote
0 answers

PHP_CodeSniffer not following provided external standard

I've got an external standard, which I got out of Sonar. I specify the standard with the --standard=/path/to/standard.xml methodology. If that isn't a valid file, I get an error. So it is reading and parsing the file. My problem is in the output it…
1
vote
0 answers

phpcode sniffer unable to run in magento module

I am trying to install phpcodesniffer in my magento module project. Below is my composer.json { "name": "test/myModule", "description": "testin", "type": "magento2-module", "version": "1.0.0", "require": { "php": "^8.1" …
footy
  • 5,803
  • 13
  • 48
  • 96
1
vote
0 answers
1
vote
0 answers

Code sniffer custom PSR2.Methods.FunctionCallSignature.MultipleArguments rule

Hi I need change rule PSR2.Methods.FunctionCallSignature.MultipleArguments to using tabs. Now I have custom config:
user2219071
  • 113
  • 10
1
vote
0 answers

Why PHP_CodeSniffer shows errors No response from codesniffer?

In PhpStorm 2021.1 working with Laravel 9 I have "squizlabs/php_codesniffer": "3.7.1" installed and periodically I got errors No response from codesniffer : But I have PHP_CodeSniffer installed and checked it is installed and activated. Any hints…
mstdmstd
  • 2,195
  • 17
  • 63
  • 140
1
vote
1 answer

Interesting Question here - Why Tomorrow Date PHP and +1 Days Gives Different Time

Hello PHP DEV, I Want to know why this strange thing is happening! Example : strtotime("+1 days") returns time as UTC TIME which is current Time so why strtotime('tomorrow') returns time as 00:00:00. I noticed this show wants to know the official…
1
vote
2 answers

How to catch PHP backtick operator usage via PHP_CodeSniffer?

I've studied some "sniffs" from the "Generic" and "Squiz" coding standards that come with CodeSniffer version 1.3, and learned enough to write a few "custom" sniffs to catch some coding anti-patterns which are specific to a PHP project that I'm…
Peter
  • 2,526
  • 1
  • 23
  • 32
1
vote
2 answers

PHP Composer and PhpStorm - PHP 5.3.3 to 7.4

I am wanting to check PHP 5.3.3 scripts for compatibility to upgrade to PHP 7.4. I have PhpStorm 2022.1.2. I gather I need to install PHP_CodeSniffer, probably in PhpStorm for convenience. Composer seems to want PHP installed on my development…
IlludiumPu36
  • 4,196
  • 10
  • 61
  • 100
1
vote
0 answers

phpcs works, but output many error with it

In my project i use composer phpcs to test my code style phpcs --standard=PSR12 src/ tests/ and it's work well, all error are outputs. For example: FILE:…
Vadim
  • 11
  • 2