SwedbankPay / swedbank-pay-woocommerce-core

Swedbank Pay WooCommerce Core
https://packagist.org/packages/swedbank-pay/swedbank-pay-woocommerce-core
Apache License 2.0
0 stars 5 forks source link

PHP 8.1 error #100

Open martinvigholm opened 1 year ago

martinvigholm commented 1 year ago

Error when updating to PHP 8.1:

PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of SwedbankPay\Core\Data::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/swedbank-pay/swedbank-pay-woocommerce-core/src/SwedbankPay/Core/Data.php:132

Should be fixed with correct return value from the methods?

lakrisgubben commented 11 months ago

Just wanted to chime in here as well. :) Would be great to get this fixed. Since this library/plugin supports PHP7 (according to composer.json) adding mixed as a return type to Data::offsetGet won't work since it was introduced in PHP8: https://www.php.net/manual/en/language.types.mixed.php but adding the #[\ReturnTypeWillChange] attribute will at least suppress the warning for now. The same should be done for offsetSet and offsetUnset since they should use the void return type which wasn't introduced until PHP7.1 https://www.php.net/manual/en/migration71.new-features.php.

offsetExists can have a return type of bool set since that was introduced in PHP7: https://www.php.net/manual/en/migration70.new-features.php

Happy to make a PR if you'd like!

phpanos commented 1 week ago

Any news regarding this issue? Would love to see this fixed.