phpcs-composer icon indicating copy to clipboard operation
phpcs-composer copied to clipboard

When using in package mode, phpcompatibility/php-compatibility version used is 9.3.5

Open pabamato opened this issue 1 year ago • 2 comments

Describe the bug

If you clone the project and run composer install, it installs phpcompatibility/php-compatibility dev-develop which has the latest PHP sniffs. image

But when is installed via package in a project, is still using phpcompatibility/php-compatibility 9.3.5: image

As a temp fix I added, the alias to my project: composer require --dev phpcompatibility/php-compatibility:"dev-develop as 9.99.99"

image

Steps to Reproduce

#create composer project
composer init

#create a file for testing testphpcs 2023-12-19 16-44-33 2.

# require latest phpcs-composer
composer require --dev 10up/phpcs-composer:"^3.0"
# show current insalled version
composer show --tree phpcompatibility/php-compatibility
# run phpcs in a very basic file -> no deprecation found for PHP 8.2
./vendor/bin/phpcs test_php_8_2.php  --standard="10up-Default"
# require the develop branch of phpcompatibility/php-compatibility as an alias in your project
composer require --dev phpcompatibility/php-compatibility:"dev-develop as 9.99.99"
# show current insalled version
# should be phpcompatibility/php-compatibility dev-develop
composer show --tree phpcompatibility/php-compatibility
# run phpcs again -> should flag about utf8_encode()
./vendor/bin/phpcs test_php_8_2.php  --standard="10up-Default"
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------
 8 | WARNING | Function utf8_encode() is deprecated since PHP 8.2; Use mb_convert_encoding(), UConverter::transcode() or iconv instead
---------------------------------------------------------------------------------------------------------------------------------------

Screenshots, screen recording, code snippet

testphpcs 2023-12-19 16-55-03 testphpcs 2023-12-19 16-55-35

Environment information

No response

WordPress information

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

pabamato avatar Dec 19 '23 15:12 pabamato

Thanks for flagging this @pabamato!

I've managed to replicate this issue, but can't seem to find a way to resolve it 🤔 Do you have any thoughts here? The other option is that we add the following to the installation instructions until v10 of PHPCompatibility and V3 of PHPCompatibilityWP are released, which would resolve this issue.

composer require --dev phpcompatibility/php-compatibility:"dev-develop as 9.99.99"

darylldoyle avatar Dec 21 '23 16:12 darylldoyle

Hi @darylldoyle, thanks for checking. I'm not sure we can resolve the issue without requiring the package at the project level. The proposed solution works for me.

pabamato avatar Jan 12 '24 17:01 pabamato