BeVariant throws a PHP Runtime Deprecation Notice
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?
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.
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.
@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.
Can confirm, the error is gone with the new versions. Thanks!
So this is solved and can be closed!? :)
This is open as an reminder for me. I've to update several extensions.