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

PHPCS - Type Hint with alias

I am using phpcs with Squiz_Sniffs_Commenting_FunctionCommentSniff, and I get a message error "Expected type hint 'My\Namespace\Interface'; found 'AliasInterface' for $var at position 1. I declare namespace at top of class adding alias and the…
fdias
  • 87
  • 5
0
votes
0 answers

PHP Equivalent of Java's @Override When Implementing Interface (For check style)

PHPCS is complaining about php doc for implementations of interfaces that already have the php doc provided in the interface. My question is, how do I cleanly get PHPCS to ignore interface method implementations, similar to java's @Override? Below…
James Oravec
  • 19,579
  • 27
  • 94
  • 160
0
votes
1 answer

PHPCS ruleset.xml "Checked in xxx"

When I am looking at the PSR2 ruleset.xml as an example, I see a lot of commented blocks saying Here is a little snippet…
lockdoc
  • 1,539
  • 1
  • 18
  • 31
-1
votes
1 answer

PHPCompatibility with PHP Code Sniffer, with PHP in Docker/Shell, fails to create CodeSniffer.conf , Read-only file system in phar

I'm trying to run PHP Compatibility tests, using this tool set: https://github.com/PHPCompatibility/PHPCompatibility I have the phpcs (PHP Code Sniffer) as a .phar file. And I use an alias for the "phpcs" as well as my php , Here are my aliases so…
Pablo Camara
  • 460
  • 4
  • 13
-1
votes
1 answer

How to sanitize global PHP variables in WordPress and WooCommerce

I have small WP plugin, in it I have php Ajax handler file, where I can not use wordpress methods. In this file I do simple check: isset($_REQUEST['action']) && 'woocommerce_refund_line_items' !== strval($_REQUEST['action']) When I try to pass WC…
-1
votes
2 answers

Include Excluded rule

I want to include the PSR12 ruleset (which includes the rule "PSR1.Methods.CamelCapsMethodName.NotCamelCaps") but I don't want that rule to run on a specific file. so I tried the following ruleset:
-2
votes
1 answer

why vscode phpcs extension fails after removing PEAR coding standard folder

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 Zend) from below…
IT_man2018
  • 53
  • 7
1 2 3
13
14