Skip to content

Commit

Permalink
Merge pull request #617 from extcode/611-add-ci-tests-for-php-84-back…
Browse files Browse the repository at this point in the history
…port

[BUGFIX] Add tests and fixes for PHP 8.4
  • Loading branch information
extcode authored Jan 7, 2025
2 parents 97a9075 + 2b12385 commit f47d638
Show file tree
Hide file tree
Showing 23 changed files with 130 additions and 44 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- 8.1
- 8.2
- 8.3
- 8.4
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -93,6 +94,8 @@ jobs:
typo3-version: '^12.4'
- php-version: '8.3'
typo3-version: '^12.4'
- php-version: '8.4'
typo3-version: '^12.4'
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -130,6 +133,9 @@ jobs:
- name: Run Unit Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-unit

- name: Run Unit Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit

- name: Run Functional Tests PHP8.1
run: nix-shell --pure --run project-test-functional

Expand All @@ -139,3 +145,6 @@ jobs:
- name: Run Functional Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-functional

- name: Run Functional Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional

12 changes: 12 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ lint:php83:
variables:
CONTAINER_IMAGE: php:8.3-alpine

lint:php84:
<<: *lint_php
variables:
CONTAINER_IMAGE: php:8.4-alpine

phpstan:analyse:
image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
stage: lint
Expand Down Expand Up @@ -119,6 +124,13 @@ test:php83:typo3_12:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.3:main
TYPO3_VERSION: ^12.4

# Build in PHP 8.4 and TYPO3 12.4
test:php84:typo3_12:
<<: *test_php
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.4:main
TYPO3_VERSION: ^12.4

documentation:
stage: documentation
image:
Expand Down
20 changes: 20 additions & 0 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ parameters:
count: 1
path: ../Classes/Controller/Cart/OrderController.php

-
message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$price follows optional parameter \\$beVariant\\.$#"
count: 1
path: ../Classes/Domain/Model/Cart/BeVariant.php

-
message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$priceCalcMethod follows optional parameter \\$beVariant\\.$#"
count: 1
path: ../Classes/Domain/Model/Cart/BeVariant.php

-
message: "#^Deprecated in PHP 8\\.0\\: Required parameter \\$sku follows optional parameter \\$beVariant\\.$#"
count: 1
path: ../Classes/Domain/Model/Cart/BeVariant.php

-
message: "#^Deprecated in PHP 8\\.1\\: Required parameter \\$title follows optional parameter \\$beVariant\\.$#"
count: 1
path: ../Classes/Domain/Model/Cart/BeVariant.php

-
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:getTaxClass\\(\\)\\.$#"
count: 2
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/Cart/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ protected function initializeView(CartTemplateView $view): void
}

public function showAction(
Item $orderItem = null,
BillingAddress $billingAddress = null,
ShippingAddress $shippingAddress = null
?Item $orderItem = null,
?BillingAddress $billingAddress = null,
?ShippingAddress $shippingAddress = null
): ResponseInterface {
$this->restoreSession();

Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/Cart/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function initializeCreateAction(): void

#[IgnoreValidation(['value' => 'shippingAddress'])]
public function createAction(
Item $orderItem = null,
BillingAddress $billingAddress = null,
ShippingAddress $shippingAddress = null
?Item $orderItem = null,
?BillingAddress $billingAddress = null,
?ShippingAddress $shippingAddress = null
): ResponseInterface {
$this->restoreSession();

Expand Down
9 changes: 0 additions & 9 deletions Classes/Controller/Cart/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Extcode\Cart\Domain\Model\Cart\Product;
use Extcode\Cart\Event\CheckProductAvailabilityEvent;
use Extcode\Cart\Event\RetrieveProductsFromRequestEvent;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
Expand All @@ -24,14 +23,6 @@ class ProductController extends ActionController
{
public const AJAX_CART_TYPE_NUM = '2278001';

public function __construct(
EventDispatcherInterface $eventDispatcher = null
) {
if ($eventDispatcher !== null) {
$this->eventDispatcher = $eventDispatcher;
}
}

public function addAction(): ResponseInterface
{
if (!$this->request->hasArgument('productType')) {
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Cart/BeVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class BeVariant

public function __construct(
protected string $id,
Product $product = null,
self $beVariant = null,
?Product $product = null,
?self $beVariant = null,
protected string $title,
protected string $sku,
protected int $priceCalcMethod,
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ public function setCurrencySign(string $currencySign): void
$this->currencySign = $currencySign;
}

public function translatePrice(float $price = null): ?float
public function translatePrice(?float $price = null): ?float
{
if ($price !== null) {
$price /= $this->getCurrencyTranslation();
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Cart/Extra.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
protected TaxClass $taxClass,
protected bool $isNetPrice = false,
protected string $extraType = '',
Service $service = null
?Service $service = null
) {
$this->service = $service;

Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Cart/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
protected TaxClass $taxClass,
protected int $quantity,
protected bool $isNetPrice = false,
FeVariant $feVariant = null
?FeVariant $feVariant = null
) {
if ($feVariant) {
$this->feVariant = $feVariant;
Expand Down Expand Up @@ -275,7 +275,7 @@ public function getQuantityDiscounts(): array
return $this->quantityDiscounts;
}

public function getQuantityDiscountPrice(int $quantity = null): float
public function getQuantityDiscountPrice(?int $quantity = null): float
{
$price = $this->getTranslatedPrice();

Expand All @@ -300,7 +300,7 @@ public function setQuantityDiscounts(array $quantityDiscounts): void
/**
* Returns Best Price (min of Price and Special Price)
*/
public function getBestPrice(int $quantity = null): ?float
public function getBestPrice(?int $quantity = null): ?float
{
$bestPrice = $this->getQuantityDiscountPrice($quantity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function addProductVariants(Product $product): void

protected function addFeVariants(
\Extcode\Cart\Domain\Model\Order\Product $product,
FeVariant $feVariant = null
?FeVariant $feVariant = null
): void {
if ($feVariant) {
$feVariantsData = $feVariant->getVariantData();
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/TaxClassService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
/**
* @return TaxClass[]
*/
public function getTaxClasses(string $countryCode = null): array
public function getTaxClasses(?string $countryCode = null): array
{
$taxClasses = [];
$taxClassSettings = $this->settings['taxClasses'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/TaxClassServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ interface TaxClassServiceInterface
/**
* @return TaxClass[]
*/
public function getTaxClasses(string $countryCode = null): array;
public function getTaxClasses(?string $countryCode = null): array;
}
30 changes: 30 additions & 0 deletions Documentation/Changelog/9.3/Breaking-611-ChangePhpDependency.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. include:: ../../Includes.rst.txt

======================================
Breaking: #611 - Change PHP Dependency
======================================

See `Issue 611 <https://github.com/extcode/cart/issues/611>`__

Description
===========

Tests with newer versions of phpstan under newer php versions showed that the
constructor method `\Extcode\Cart\Domain\Model\Cart\BeVariant::__construct()` uses
required method parameters after optional parameters. This is deprecated since.
PHP 8.0. (see https://php.watch/versions/8.0/deprecate-required-param-after-optional)

As this may lead to an error in a later PHP version, compatibility is restricted
to PHP 8.1-8.4.

Affected Installations
======================

All installations.

Migration
=========

This restriction currently has no effect. No migration is necessary.

.. index:: API
20 changes: 20 additions & 0 deletions Documentation/Changelog/9.3/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: ../../Includes.rst.txt

9.3 Changes
===========

**Table of contents**

.. contents::
:local:
:depth: 1

Breaking
--------

.. toctree::
:maxdepth: 1
:titlesonly:
:glob:

Breaking-*
1 change: 1 addition & 0 deletions Documentation/Changelog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ChangeLog
:maxdepth: 5
:titlesonly:

9.3/Index
9.1/Index
9.0/Index
8.5/Index
Expand Down
4 changes: 2 additions & 2 deletions Documentation/guides.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
interlink-shortcode="extcode/cart"
/>
<project title="Cart"
release="9.2.0"
version="9.2"
release="9.3.0"
version="9.3"
copyright="2018 - 2024"
/>
<inventory id="t3tsref" url="https://docs.typo3.org/typo3cms/TyposcriptReference/"/>
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ Sometimes minor versions also result in minor adjustments to own templates or co

## 3.1 Compatibility and supported Versions

| Cart | TYPO3 | PHP | Support/Development |
|-------|------------|-----------|--------------------------------------|
| 9.x.x | 12.0 | 8.1+ | Features, Bugfixes, Security Updates |
| 8.x.x | 10.4, 11.5 | 7.2+ | Features, Bugfixes, Security Updates |
| 7.x.x | 10.4 | 7.2 - 7.4 | Security Updates |
| 6.x.x | 9.5 | 7.2 - 7.4 | |
| 5.x.x | 8.7 | 7.0 - 7.4 | |
| 4.x.x | 7.6 - 8.7 | 5.6 - 7.2 | |
| 3.x.x | 6.2 - 8.7 | 5.6 - 7.0 | |
| 2.x.x | | | |
| 1.x.x | | | |
| Cart | TYPO3 | PHP | Support/Development |
|--------|------------|-----------|--------------------------------------|
| 9.x.x | 12.4 | 8.1 - 8.4 | Features, Bugfixes, Security Updates |
| 8.x.x | 10.4, 11.5 | 7.2+ | Features, Bugfixes, Security Updates |
| 7.x.x | 10.4 | 7.2 - 7.4 | Security Updates |
| 6.x.x | 9.5 | 7.2 - 7.4 | |
| 5.x.x | 8.7 | 7.0 - 7.4 | |
| 4.x.x | 7.6 - 8.7 | 5.6 - 7.2 | |
| 3.x.x | 6.2 - 8.7 | 5.6 - 7.0 | |
| 2.x.x | | | |
| 1.x.x | | | |

If you need extended support for features and bug fixes outside of the currently supported versions,
we are happy to offer paid services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function getTypeZonePluginSettingsReturnsTypeZoneSettings(): void

private function createSubject(array $configurations)
{
$configurationManager = $this->createStub(ConfigurationManagerInterface::class);
$configurationManager = self::createStub(ConfigurationManagerInterface::class);
$configurationManager->method('getConfiguration')->willReturn($configurations);

return new class ($configurationManager, new ServiceFactory()) extends AbstractConfigurationFromTypoScriptService {};
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Service/TaxClassServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ public function parsingTaxClassesFromTypoScriptWithIntegerZeroAsCalcIsValid(): v

private function createSubject(array $settings): TaxClassService
{
$configurationManager = $this->createStub(ConfigurationManagerInterface::class);
$configurationManager = self::createStub(ConfigurationManagerInterface::class);
$configurationManager->method('getConfiguration')->willReturn($settings);

return new TaxClassService(
$configurationManager,
new TaxClassFactory(
$this->createStub(LoggerInterface::class)
self::createStub(LoggerInterface::class)
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
},
"require": {
"php": "^8.1",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"ext-json": "*",
"ext-openssl": "*",
"typo3/cms-core": "^12.4",
Expand Down
5 changes: 4 additions & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
'title' => 'Cart',
'description' => 'Shopping Cart(s) for TYPO3',
'category' => 'plugin',
'version' => '9.2.0',
'version' => '9.3.0',
'state' => 'stable',
'author' => 'Daniel Gohlke',
'author_email' => '[email protected]',
'author_company' => 'extco.de UG (haftungsbeschränkt)',
'constraints' => [
'depends' => [
'php' => '8.1.0-8.4.99',
'typo3' => '12.4.0-12.4.99',
'extbase' => '12.4.0-12.4.99',
'fluid' => '12.4.0-12.4.99',
],
'conflicts' => [],
'suggests' => [],
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ConvertImplicitVariablesToExplicitGlobalsRector::class,
])
->withConfiguredRule(ExtEmConfRector::class, [
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.1.0-8.3.99',
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.1.0-8.4.99',
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '12.4.0-12.4.99',
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [],
])
Expand Down

0 comments on commit f47d638

Please sign in to comment.