Skip to main content
Filter by
Sorted by
Tagged with
2 votes
0 answers
47 views

I have those rules: <rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"> <include-pattern>/src\/Module\/Quotes\/Adapter\/Incoming/</include-pattern&...
Simon's user avatar
  • 1,137
1 vote
1 answer
70 views

I'm working on a WordPress plugin and keep getting a PHPCS warning that I can't seem to resolve. The warning is: WARNING WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber Incorrect number ...
tssaini's user avatar
  • 23
2 votes
1 answer
50 views

I am currently working on a standard formatting configuration for my PHP project. I want to use the PSR-12 rules, but I prefer to disable the rule that forces the opening curly brace to be on the same ...
Dayvson Spacca's user avatar
0 votes
1 answer
45 views

squizlabs/php_codesniffer/bin/phpcbf fails with this error: php vendor/squizlabs/php_codesniffer/bin/phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml ...
Himanshu Lahare's user avatar
0 votes
1 answer
53 views

If I try to run phpcbf --version vscode opens and shows The editor could not be opened due to an unexpected error: Unable to resolve resource phar://c:/PHP_Tools/phpcbf/src/Config.php (Sometimes it's ...
Daviid's user avatar
  • 1,601
2 votes
3 answers
162 views

I've managed to enforce strict types, but now I need to declare them in every file. phpcbf says it has 0 fixable issues upon running. Is there a way to automatically add declare(strict_types = 1); to ...
ashdoestech's user avatar
0 votes
0 answers
98 views

I'm looking to enforce a specific method chaining style in PHP, particularly to differentiate between what I consider the 'wrong' and 'good' styles. Is there a tool or method that can help check and ...
Stevan Tosic's user avatar
  • 7,317
0 votes
3 answers
328 views

I am attempting to write a little simple phpcs (phpcbf) sniff to remove whitespace within empty curly braces. I've written quite a few small fixers, and this seemed like it should be very easy. ...
donatJ's user avatar
  • 3,404
-1 votes
1 answer
54 views

I'm at a loss, I hope someone can explain what I'm doing wrong: I'm working on macOS (10.15.7). I tried to update PHPCS via Composer: composer global require "squizlabs/php_codesniffer=*" ...
berlindave's user avatar
0 votes
0 answers
84 views

$template_html = sanitize_post_field('template_content_html',$_POST['template_content_html'], $post_id, 'db' ); I'm saving some HTML in post meta but i don't want lose any html while sanitizing but ...
Ifat's user avatar
  • 79
0 votes
1 answer
98 views

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 ...
JakeParis's user avatar
  • 11.2k
4 votes
0 answers
150 views

I have created a project based on php 7.4. I plan to move to php 8.2. In php 8.2, in a class, it is forbidden to declare properties dynamically. I would like to add a rule to PHPCS that would ...
AtyKlaxas's user avatar
0 votes
1 answer
790 views

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 ...
Wolf-Tech's user avatar
  • 1,309
0 votes
0 answers
181 views

in my current project i'm using the following configuration composer.json: "require-dev": { "php": "^7.4 || ^8.0", "dealerdirect/phpcodesniffer-composer-...
user1956396's user avatar
1 vote
1 answer
1k views

I have read the documentation from both formatters and have tried different configurations using various coding styles with different arguments with no success. Here's a code snippet of how my ...
Rafael Cano's user avatar
0 votes
1 answer
1k views

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 ...
Arafath's user avatar
  • 1,090
0 votes
0 answers
586 views

php cs fixer is formatting the code as follows, by removing space between the function call and the parenthesis - public function __invoke (array $addedValues, array $args, Context $context, ...
Shobi's user avatar
  • 11.7k
0 votes
0 answers
42 views

I'm creating a custom rule config for our project and want to use the PEAR rule 'PEAR.Commenting.ClassComment'. But this rule checks more then we need. Like @package and @category. Is there a way to ...
Peter van Garderen's user avatar
0 votes
1 answer
226 views

I am trying to create my own ruleset for PHPCS extending the WordPress standard. My goal is to define that a opening brace starts as the same line as the function name. public function __construct(...
Ted Logan's user avatar
  • 434
3 votes
1 answer
2k views

I am running phpcs with the following command: php -d memory_limit=-1 vendor/bin/phpcs -v -p . --standard=PHPCompatibility --extensions=php --colors --runtime-set testVersion 8.1 However, it is only ...
Bill Johnson's user avatar
2 votes
1 answer
138 views

PHPCS is reporting <error line="5" column="1" severity="warning" message="Unused use statement" source="Drupal.Classes.UnusedUseStatement.UnusedUse&...
Monkeybrain's user avatar
0 votes
1 answer
337 views

I have a little function in a class: /** * @return float|int */ private function getPrice() { return rand(1000, 1000000) / 10; } In PhpStorm I am getting a warning by phpcs. Missing function's ...
vaso123's user avatar
  • 12.4k
0 votes
1 answer
259 views

I am inside my project directory that has various files/folders and some have PHP8 fatal errors I have found when using the website (e.g. Fatal error: Uncaught Error: Non-static method), I am using ...
bigdaveygeorge's user avatar
0 votes
1 answer
302 views

I have a vscode plugin that uses phpcs for linting. I get this error: phpcs: Unknown error ocurred. Please verify that C:\Users\David\AppData\Roaming\Composer\vendor\bin\phpcs --report=json -q --...
Daviid's user avatar
  • 1,601
0 votes
1 answer
266 views

I'm using phpcs When using code very similar to this(slightly altered for legal reasons): function methodNameHere($desiredParameter){ $client = new Client([ 'base_uri' => '...
JB3's user avatar
  • 40
0 votes
0 answers
359 views

I have a dockerized WSL with PHP code sniffer installed. Now I stuck to set up "wordpress" coding standard. When I run phpcs -i from WSL it then shows The installed coding standards are ...
John Smith's user avatar
  • 6,259
1 vote
1 answer
647 views

The issue is that if watching multiple directories via the Finder class. If one does not exist, the Finder will throw an exception and the fixer will die. $finder = Finder::create() ->in([ ...
ruckie's user avatar
  • 159
1 vote
0 answers
573 views

We have a large codebase and it's currently running in production on PHP 7.4. Now we're getting ready to upgrade to PHP 8.1 and so we've been asked to make sure the code is going to work when we ...
Emmet O'Grady's user avatar
1 vote
0 answers
214 views

I am using vscode editing legacy php code. The phpcs extensions is great in finding potential problems. However, the old code is using tab instead of 4 spaces for indentation. phpcs would report with: ...
Nick's user avatar
  • 9,163
0 votes
2 answers
798 views

Maintaining some legacy code, phpcs (in Vim, using ALE) shows a lot of errors. I'd like to suppress them (for now). I get errors like: participant.php|1 col 1 error| Header blocks must be separated by ...
klokop's user avatar
  • 2,410
0 votes
1 answer
295 views

Is there a way to sanitize a $_REQUEST[object] to satisfy the phpcs standards for WordPress? Below is what I have so far but phpcs still errors on the earliest assignment of the request and I cannot ...
oooorgle's user avatar
0 votes
1 answer
700 views

I'm trying to (temporarily) ignore some errors about not using Nonces. I've tried using // @codingStandardsIgnoreLine. before the line, and I've tried using // phpcs:ignore WordPress.Security....
gillespieza's user avatar
1 vote
0 answers
754 views

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: /home/user/PhpstormProjects/php-vadzim-...
Vadim's user avatar
  • 11
1 vote
0 answers
295 views

I tested my code and encountered an error on mess detector. It seems like PHP Mess Detector did not allow private methods to be prefixed with underscore as it did not fulfil mess detector requirements,...
peanutbutter's user avatar
0 votes
1 answer
170 views

I want to make sure all classes in some dir (src/Controller/CP) extend some other class AbstractCPController. So that class SupportTicketTagController extends AbstractController would show PHPCS ...
michnovka's user avatar
  • 3,477
2 votes
1 answer
993 views

I am trying to find rule which will enforce ONLY properties to be in $snake_case I have this for CamelCase: <rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps"/> Is ...
michnovka's user avatar
  • 3,477
1 vote
0 answers
240 views

I tried couple of sniffs in my phpcs.xml file but couldn't come up with a solution for such cases: $arrays = array("1", 2, 2 , 3 ); // not allowed due to extra whitespaces $arrays = [1 , 2 ...
mirza's user avatar
  • 5,821
0 votes
0 answers
908 views

I use PhpStorm 2021.3 on MacOS (Apple Sillicon M1). I'm not sure the problem is with PhpStorm but PHP Code Sniffer doesn't work. When I type this command it doesn't show any errors in the code and I'm ...
pirmax's user avatar
  • 2,143
1 vote
0 answers
171 views

Sometimes I open a php file in VS Code and no linting occurs until I open the linting console from the bottom, switch over to the terminal pane where a dialog shows up that asks me if I trust the ...
ubsd's user avatar
  • 35
4 votes
3 answers
6k views

Just installed php_codesniffer and coder: composer global require "squizlabs/php_codesniffer=*" composer global require drupal/coder After installation, run phpcs -i and the result is as ...
River Zhao's user avatar
1 vote
1 answer
392 views

After doing some digging online there doesn't seem to be an immediate answer to this. I am writing code for a closed source application and when running PHPCS its informing me that an @license tag is ...
Xenology's user avatar
  • 2,512
-2 votes
1 answer
339 views

I was going to remove (uninstall) PEAR and Zend standards from my phpcs (provided by composer installation in my windows 11) according to this answer i manually deleted these two folders (PEAR and ...
IT_man2018's user avatar
3 votes
2 answers
2k views

After installing Composer in windows 10, the result of phpc -i command is: "The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend." After lots of searches I ...
IT_man2018's user avatar
2 votes
3 answers
7k views

When I execute git commit, I get this error: ERROR: the "PHPCompatibility" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz, ...
River Zhao's user avatar
2 votes
0 answers
178 views

I am already using phpcs/phpcbf for sniffing my code. Unfortunately, I cannot find a tool or a rule for PHPCS which can automatically organize my imports. I know something like this exists for IDE's ...
Matthias Günter's user avatar
4 votes
1 answer
2k views

I would like to exclude everything except some directories from PHP Code Sniffer inspection in my project. Something similar like git repo exclusions with .gitignore I had the idea that regex with ...
kanlukasz's user avatar
  • 1,354
2 votes
0 answers
166 views

I'm developing a Laravel application, and I use PHPCS, PHPMD and Prettier. I have a Facade to deal with the invitation system of the app, and the PHPDoc (at the time of writing) looks like this: /** *...
glaucomorais's user avatar
1 vote
1 answer
611 views

I'm trying to configure PHP Code Sniffer on my project, and I would like to see the error/warnings directly on the editor - like any other error, warnings. I installed the package in composer ...
Mistre83's user avatar
  • 2,817
1 vote
1 answer
551 views

I am trying to check for errors via phpcs and PHPCompatibility standard on a laravel project, here is the command: phpcs -psvw app --extensions=php --standard=PHPCompatibility --runtime-set ...
dev0010's user avatar
  • 95
2 votes
1 answer
319 views

is there any Customizable Sniff Properties for classes/traits/interfaces to do the followings; not allow a blank line before the first content One blank line after the last content I am expecting a ...
Safry's user avatar
  • 191

1
2 3 4 5