php-stubs / woocommerce-stubs

WooCommerce function and class declaration stubs for static analysis
https://packagist.org/packages/php-stubs/woocommerce-stubs
MIT License
83 stars 10 forks source link

PHP 8.1 - Throwing deprecated warnings #16

Closed benjaminprojas closed 2 years ago

benjaminprojas commented 2 years ago

I'm seeing these errors when running PHPStan with WooCommerce Stubs:

PHP Deprecated:  Optional parameter $id declared before required parameter $object is implicitly treated as a required parameter in .../vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php on line 73141
szepeviktor commented 2 years ago

Hello @benjaminprojas! Yes, these problems may occur. made by WooCommerce

What is your proposal?

benjaminprojas commented 2 years ago

This can be fixed by declaring $object as "optional" by setting its default value to an empty array. See #18.

szepeviktor commented 2 years ago

Here is the solution. In this commit

https://github.com/woocommerce/woocommerce/pull/34396/commits/5a484b76c3dd396f1b8541004aa7058cfa3d1467

https://github.com/woocommerce/woocommerce/pull/34396

Hold on tight! WC 7.1.0 will be released soon 🎉

benjaminprojas commented 2 years ago

Oh boy 🤦🏻 I feel bad for anyone using that public method and updates without understanding the consequences!

Will look for this fix then once WC 7.1.0 is out 😄