WordPress-Coding-Standards: PHP Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /srv/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php on line 32 in

Bug Description

Because of no PHP 8.1 support yet, it causes issue with phpcs / phpcbf.

See https://github.com/squizlabs/PHP_CodeSniffer/issues/3677

These places it needs to be fixed:

Until full support is added #2070, maybe a small fix release fixing it would be nice?

Question Answer
PHP version 8.1.7
PHP_CodeSniffer version 3.7.1
WPCS version 2.3.0

Tested Against develop branch?

  • I have verified the issue still exists in the develop branch of WPCS.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

composer require wp-coding-standards/wpcs:"dev-develop"

You may need to add minimum-stability: dev as well.

@saas786

I can’t use develop

Why not?

Because it brings in in-progress / unstable code into my repo, I don’t want to chase things down if something is not working as it should. But if above fix is implemented and its released, I know what changes I am bringing in, and don’t have to worry about it, as have been using 2.3.0 long time now.

@jrfnl Getting there. So dev-[branch-name](/[some-feature]) is a Composer syntax/feature, where is is checking for the string dev-?

I think this page of the Composer documentation may help: https://getcomposer.org/doc/articles/aliases.md

You rock, by the way.

Always nice to hear 😉

So, you can use develop, but you choose not to.

You could, of course, pull in a particular commit: either the head of develop as it is today, or find where the fix was added that you’re affected by and use that commit instead - that way the list of changes is fixed.

The three items you highlighted were fixed in #1984 and #1985. So https://github.com/WordPress/WordPress-Coding-Standards/commit/2fdc57f70b8d1c027b6393362226b880ef88f087 would include those fixes.

Here is the list of changes from 2.3.0 to 2fdc57f.

And the list of changes from 2fdc57f to the head of develop.

I think it’s this one: #2035

You can just search the issues for the relevant information 😉

Thanks, but there is nothing there which resolves my issue, I can’t use develop and I see no solution out there which resolves it.

I did some quick search and found no helpful solutions / answers, that’s why asked you.

Anyway, I understand the reasoning, so no problem.

I think it’s this one: https://github.com/WordPress/WordPress-Coding-Standards/issues/2035

You can just search the issues for the relevant information 😉

Closing as duplicate. This has been asked and answered multiple times before.

Could you please point me to relevant questions where you have provided an answer? I could benefit from those replies as well. Thanks.