wp-cli / wp-cli-dev

🛠 WP-CLI development environment that allows for easy development across all packages
36 stars 36 forks source link

Tests failing with default composer install #47

Closed justinmaurerdotdev closed 10 months ago

justinmaurerdotdev commented 10 months ago

Bug Report

Describe the current, buggy behavior Some syntax issues in my commits haven't been caught because I haven't been able to run the full test suite. This is because of a PHPCS error I've been getting in my environment. @danielbachhuber saw it on contributor day, but wasn't sure how to fix. The message is below, and appears any time I try to run composer test.

> run-linter-tests
PHP 8.2.9 | 10 parallel jobs
..                                                           2/2 (100 %)

Checked 2 files in 0 seconds
No syntax error found
> run-phpcs-tests
EE 2 / 2 (100%)

FILE: media-command.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: trim(): Passing null to parameter #1 ($string) of type string is deprecated in
   |       | /Users/justinmaurer/dev/wp-cli-dev/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php on line 194
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: src/Media_Command.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: trim(): Passing null to parameter #1 ($string) of type string is deprecated in
   |       | /Users/justinmaurer/dev/wp-cli-dev/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php on line 194
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 111ms; Memory: 12MB

Script run-phpcs-tests handling the phpcs event returned with error code 1
Script @phpcs was called via test

It's happening with PHP 8.1 and 8.2. For some reason this doesn't seem to be happening in the automated commit tests (at least in the media-command repo), and is happening even with a fresh composer install in the wp-cli-dev repo, on the main branch. So I guess it might be something with my particular environment. Any suggestions?

danielbachhuber commented 10 months ago

I'm experiencing the same issue. I'm not sure what it is, though. Upgrading might fix it https://github.com/wp-cli/wp-cli-tests/issues/175

swissspidy commented 10 months ago

Yeah that's one of the PHP 8 compat issues that got resolved in WPCS 3.0. We should definitely get that upgrade sorted.

danielbachhuber commented 10 months ago

Started with https://github.com/wp-cli/wp-cli-tests/pull/176.

I think we'll need to tag a wp-cli-tests 4.0.0 release, and then update each repository individually.