cart icon indicating copy to clipboard operation
cart copied to clipboard

BeVariant throws a PHP Runtime Deprecation Notice

Open knusperpixel opened this issue 11 months ago • 6 comments

Bug Report

Current Behavior The class Classes/Domain/Model/Cart/BeVariant.php throws a PHP Runtime Deprecation Notice: Optional parameter $product declared before required parameter $price is implicitly treated as a required parameter in /var/www/vendor/extcode/cart/Clas
ses/Domain/Model/Cart/BeVariant.php line 46

Expected behavior/output Run the extension without deprecation warnings.

Environment

  • TYPO3 version(s): 12.4.26
  • cart version: >=9.3.0
  • Is your TYPO3 installation set up with Composer (Composer Mode): yes
  • PHP: 8.3

Possible Solution In this commit you changed the constructor parameters $productand $beVariant to be optional - maybe undo this?

knusperpixel avatar Jan 22 '25 08:01 knusperpixel

The function parameters were already optional before. With the support of PHP 8.4 and the addition of tests, the parameter type was also declared as nullable. (see: https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated)

However, fixing this bug as implemented in the TYPO3 v13 version is a breaking change as it fundamentally changes the API of this method. This change would not only affect cart, but would also have to be taken into account in cart_products and all other product extensions. The best approach would probably be to stop developing version 9.x and move the changes to version 10 with a breaking change. The current version 10 for TYPO3 v13 would then have to continue to run as version 11.

I'm not sure how best to communicate this, as the major version is rarely updated in (third-party) projects. I cannot guarantee that 9.x and 10.x will continue to be developed in parallel for TYPO3 v12.

I will think about the whole thing again and assess the effort involved.

extcode avatar Jan 22 '25 19:01 extcode

I have decided to bring out a new major release for TYPO3 v12. This is prepared so far. I will now adapt the product extensions to this major release.

extcode avatar Jan 31 '25 15:01 extcode

@knusperpixel Can you have a look at extcode/cart-products v6.0.0 and extcode/cart v10.0.0. This should fix the PHP Runtime Deprecation Notice.

extcode avatar Jan 31 '25 22:01 extcode

Can confirm, the error is gone with the new versions. Thanks!

seirerman avatar Feb 03 '25 09:02 seirerman

So this is solved and can be closed!? :)

rintisch avatar Feb 10 '25 19:02 rintisch

This is open as an reminder for me. I've to update several extensions.

extcode avatar Feb 10 '25 21:02 extcode