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:
- https://github.com/WordPress/WordPress-Coding-Standards/blob/2.3.0/WordPress/Sniffs/WP/I18nSniff.php#L194
- https://github.com/WordPress/WordPress-Coding-Standards/blob/2.3.0/WordPress/Sniff.php#L1144
- https://github.com/WordPress/WordPress-Coding-Standards/blob/2.3.0/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php#L280
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
developbranch of WPCS.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (7 by maintainers)
You may need to add
minimum-stability: devas well.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.0long time now.I think this page of the Composer documentation may help: https://getcomposer.org/doc/articles/aliases.md
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
developas 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.Thanks, but there is nothing there which resolves my issue, I can’t use
developand 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 😉
Could you please point me to relevant questions where you have provided an answer? I could benefit from those replies as well. Thanks.