Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:52
    jrfnl commented #2387
  • Jan 31 2019 22:41
    valeryan commented #2386
  • Jan 31 2019 22:40
    valeryan commented #2386
  • Jan 31 2019 22:40
    valeryan commented #2386
  • Jan 31 2019 22:17
    gsherwood commented #2387
  • Jan 31 2019 22:14
    gsherwood milestoned #2387
  • Jan 31 2019 22:13
    gsherwood labeled #2386
  • Jan 31 2019 22:13
    gsherwood commented #2386
  • Jan 31 2019 22:05
    gsherwood milestoned #2388
  • Jan 31 2019 22:03
    gsherwood labeled #2394
  • Jan 31 2019 22:02
    gsherwood commented #2394
  • Jan 31 2019 22:02
    gsherwood closed #2394
  • Jan 31 2019 22:02

    gsherwood on master

    Fixed docblocks Because customā€¦ (compare)

  • Jan 31 2019 22:02
    gsherwood milestoned #2394
  • Jan 31 2019 16:50
  • Jan 31 2019 16:00
    SteepDevs starred squizlabs/PHP_CodeSniffer
  • Jan 31 2019 15:22
  • Jan 31 2019 14:39
    sebastiaanluca commented #2304
  • Jan 31 2019 14:38
    sebastiaanluca commented #2304
  • Jan 31 2019 13:09
    rlauenroth starred squizlabs/PHP_CodeSniffer
Marco Polichetti
@gremo
<file>./src/</file>
<exclude-pattern>var/*</exclude-pattern>
<exclude-pattern >vendor/*</exclude-pattern>
The above is working...
But this is not working:
<file>./src/</file>
<exclude-pattern type="relative">^./var/*</exclude-pattern>
<exclude-pattern type="relative">^./vendor/*</exclude-pattern>
Anyone knows why?
Chetan PrajapatišŸ‡®šŸ‡³
@iamchetanp_twitter
I am getthing this error on VSCode phpcs: The "WordPress" coding standard is not installed. Please review your configuration an try again.
Chetan PrajapatišŸ‡®šŸ‡³
@iamchetanp_twitter
This has been fixed! :)
Dmitry Zelonkin
@dmitry.zelonkin_gitlab
Hello guys! Is it possible to detect unused php imports?
Faithu
@Faithu
hello
i don't suppose anyone is active to help me?
abyong123
@abyong123
anybody active?
Glen
@glen-84
@jrfnl Hi Juliette. Do you know why I would get ERROR: Referenced sniff "PHPCS23Utils" does not exist when running phpcs --standard=PHPCompatibility?
@gsherwood Hi Greg. Has Gitter been disconnected from the PHPCS repo? The activity on the right is outdated.
Glen
@glen-84
nvm Juliette, I had to switch to the master branch (wasn't mentioned in the README).
1 reply
Juliette
@jrfnl
@glen-84 Ah yes, the README has not been updated for the changes in the upcoming 10.0.0 release yet, in an attempt to prevent confusing people terribly with install instructions which wouldn't work (yet).
Generally speaking using a tagged release will always be best.
If you prefer to use bleeding edge develop, I can help you get that working, but I'd need a little more information on how you've installed and are running PHPCS/PHPCompatibility (Phar, clones, Composer).
Glen
@glen-84
@jrfnl Does the current release include some support for PHP 8, or is that only in 10.x?
Juliette
@jrfnl
@glen-84 9.3.5 has hardly anything on PHP 8, maybe a few small things which were deprecated in PHP 7.x and for which it was already announced that they would be removed in PHP 8.
So for checking anything PHP 8 related, 10.0 (currently develop) would be your best bet and yes, 10 already contains a huge amount of new checks related to PHP 8.
Glen
@glen-84
@jrfnl Then I wouldn't mind some assistance with setting this up :slight_smile:. I have a global composer installation of PHPCS, and a clone of PHPCompat. When I'm on the develop branch, I see the error above. Is there a simple way to fix that?
Juliette
@jrfnl

@glen-84 Sort of, though having a mixed installation like that makes it slightly more awkward. Basically PHPCompat adds a new dependency and you're currently missing that dependency.
There are several ways to solve it though:

  1. On the git clone of PHPCompat, run composer install --no-dev, then use the phpcs command in the vendor/bin/ directory of PHPCompat to run the PHPCompat checks. This will only be useful if you run just and only PHPCompatibility over code.
  2. Instead of using the git clone of PHPCompat, install it globally with Composer using composer global phpcompatibility/php-compatibility:"dev-develop". You might need to make sure that your global Composer config file allows for 'minimum-stability': 'dev'. You may also want to wait until PR PHPCompatibility/PHPCompatibility#1245 has been merged to prevent a possible exception being thrown (merge expected later today). PHPCompat + PHPCSUtils should automatically register themselves with the Composer globally installed PHPCS instance as the DealerDirect Composer PHPCS plugin will be installed as well.
  3. Last option: clone PHPCSUtils as well - for now, check out the 1.0.0-alpha3 tag and register the location of PHPCSUtils with the Composer global PHPCS instance via the installed_paths config.

Does that help ?

Oops - forgetting the link to PHPCSUtils: https://github.com/PHPCSStandards/PHPCSUtils
Option 2 should be most stable, though as you are using develop, you will need to run composer global update phpcompatibility/php-compatibility --with-dependencies regularly.
Glen
@glen-84
@jrfnl I'll try #1 first. Thanks so much for the detailed instructions, and for all the work that you do.
Juliette
@jrfnl
@glen-84 You're welcome! Let me know how you get on.
Glen
@glen-84
It works, thanks again. :slight_smile:
Juliette
@jrfnl
@glen-84 Thanks for letting me know! Hope you like the new and improved PHPCompatibility. Please let me know if you find any bugs.
dstrisma
@dstrisma
Hello :) Can phpcbf not fix lowercase constants?
vladicidev
@vladicidev
Can anyone explain why \r\n line endings are reported as ERRORs with the following message: End of line character is invalid; expected "\n" but found "\r\n"
The rule is defined here: https://github.com/squizlabs/PHP_CodeSniffer/blob/2ecd990f9f19075632773b8c75cbec013eef74bf/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php
The question is why the \n line ending character is considered as the only "correct" one.
Greg Sherwood
@gsherwood
@vladicidev Because the coding standard you are checking with has decided to standardise on them, probably based on a heavy use of unix tooling over windows, and the general preference of the developers working on the project.
vladicidev
@vladicidev
Hi @gsherwood, thanks for replying me. I see what you mean and I guess the question should be addressed to PSR then, just don't get it why this is a requirement when it doesn't lead to any issues.
Michael Cordover
@mjec
Hi folks! At $dayjob we're about to embark on a phpcs upgrade, including writing some new sniffs, but we've got a bit of flexibility on when to do this. I notice there's a phpcs 4.0 branch -- what's the status of that? I'm not looking to hold anyone to a timeline, but it'd be good to know if that's roughly "right around the corner" or if it's more of a "check back in 2022" thing
Greg Sherwood
@gsherwood
@mjec Closer to 2022 than "right around the corner". I wouldn't wait for it, but worth keeping an eye on the changelog to see what's going in: https://github.com/squizlabs/PHP_CodeSniffer/blob/4.0/CHANGELOG.md
Michael Cordover
@mjec
Ah excellent, thanks Greg!
abyong123
@abyong123
anybody here who can help me?
Doug
@OdinsHat
Is there an existing rule out of the existing standards that checks for docblocks? So I don't have to create my own sniffer, etc?
Juliette
@jrfnl
@OdinsHat Both the PEAR standard as well as the Squiz standard contain various docblock related sniffs in the Commenting category and there is also the Generic.Commenting.DocComment sniff.
Doug
@OdinsHat
Ah brilliant - thank you @jrfnl :) Much appreciated.
Mark Roeling
@mroeling
Hi, question since I wasn't able to find it online: is there already a Sniff for https://wiki.php.net/rfc/trailing_comma_in_parameter_list ?
Juliette
@jrfnl
@mroeling You mean to enforce or forbid trailing comma's in parameter lists ?
The Slevomat standard has sniffs for both (only enable one to prevent conflicts): https://github.com/slevomat/coding-standard#slevomatcodingstandardfunctionsdisallowtrailingcommaindeclaration-
Other than that, the PHPCompatibility standard has a sniff which will either allow or forbid it depending on the PHP versions you indicate that your code needs to support, though that sniff is not yet in a tagged release, so you'd need to use develop for now. https://github.com/PHPCompatibility/PHPCompatibility
1 reply
DarĆ­o Rivera
@darioriverat
Hi guys, You know if there's a rule to detect unused imports ?
1 reply
Mark Harrison
@yourpropertyexpert

How am I meant to indent something like :

Class Example
{
public function __construct(
private string $username,
private \underserved\QueryRunner $query,
private \underserved\StatusWords $status
) {
}

... if I have 8 spaces before each of the Private lines (ie parameters) PHPCS tells me I need 4... but if I have 4, it tells me I need 8

?
Juliette
@jrfnl
@yourpropertyexpert What version of PHPCS are you using ? If I remember correctly most issues with this new PHP 8.0 feature were solved in PHPCS 3.6.0, though there may still be some fixes in the upcoming PHPCS 3.6.1.
Chetan PrajapatišŸ‡®šŸ‡³
@iamchetanp_twitter

Hi,

I am getting below error in VS Code. Can someone please help?

phpcs: The "WordPress" coding standard is not installed. Please review your configuration and try again.

But I have already installed standards. I have setup PHPCS using homebrew.

chetanmprajapati@Chetans-MacBook-Pro ~ % phpcs -i
The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz, Zend, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core

3 replies
Chetan PrajapatišŸ‡®šŸ‡³
@iamchetanp_twitter
image.png
Olivia Marie Valmin
@eaxexe
Hi there folks! Is there a way to stop phpcs from printing "PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY" at the end of a phpcs report? Thanks!
2 replies
Near
@nateriver74
This message was deleted
2 replies
Near
@nateriver74

Hello!,
I am using VSCode on Windows 10 and I would like to know if there is a way to declare the "phpcs.executablePath" path to the "phpcs" file without using the "username", so that when I change computers the configuration will continue to work .

I have tried declaring the route as follows:

"~/AppData/Roaming/Composer/vendor/squizlabs/php_codesniffer/bin/phpcs"

But it shows me the following error message:

phpcs: Unable to locate phpcs. Command failed: "~/AppData/Roaming/Composer/vendor/squizlabs/php_codesniffer/bin/phpcs" --version The system can not find the path specified.

Beforehand thank you very much!

Andre Polykanine
@Menelion

Hi team,
I tried to add PHPCS to my CI on Github actions but I'm getting ERROR: Referenced sniff "psr2" does not exist. Googling gave no results, unfortunately. Locally everything works as expected. Here is my .github/workflows/phpcs.yml:

name: check coding style

on: [push]

jobs:
  phpcs:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.4
          extensions: mbstring, pdo, pdo_sqlite, openssl
          coverage: none

      - name: Install dependencies
        run: composer install

      - name: run PHPCS
        run: vendor/bin/phpcs src tests

What am I missing? Thanks!

Juliette
@jrfnl
@Menelion Based on the command you are using, looks like you are using a custom ruleset - is that public somewhere ?
First thing I would suggest you check is that the reference(s) to the PSR2 standard in your ruleset are properly capitalized.
On a non-case-sensitive OS (like Windows), not following the proper capitalization will not be an issue, but on a case-sensitive OS (like Ubuntu, which you are using in GHA), it is (for the file auto-loading).
Sreten Ilic
@ilicmsreten

Hi, anyone know how to ignore error for method
public function getItem(string $resourceClass, /* array */ $id, ?string $operationName = null, array $context = []): ?Item

Error
does not have parameter type hint nor @param annotation for its parameter $id.

I tried all docs explinantion without success