From 44429528fdf32e3c4be25b941e40c6990c7a6b60 Mon Sep 17 00:00:00 2001
From: Oliver Klee <typo3-coding@oliverklee.de>
Date: Mon, 3 Feb 2025 14:27:04 +0100
Subject: [PATCH] [FEATURE] Add support for PHP 8.4 (#1536)

Comment-out GitHub Action jobs that fail with PHP 8.4 due to
incompatible dependencies.
---
 .github/workflows/ci.yml                          | 13 +++++++++++++
 .gitlab/pipeline/.gitlab-ci.yml                   |  3 +++
 .gitlab/pipeline/jobs/func-v12-php8.4-highest.yml | 14 ++++++++++++++
 .gitlab/pipeline/jobs/func-v12-php8.4-lowest.yml  | 14 ++++++++++++++
 .gitlab/pipeline/jobs/php-lint-php8.4.yml         |  7 +++++++
 .gitlab/pipeline/jobs/unit-v12-php8.4-highest.yml | 11 +++++++++++
 CHANGELOG.md                                      |  1 +
 composer.json                                     |  2 +-
 ext_emconf.php                                    |  2 +-
 rector.php                                        |  2 +-
 10 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 .gitlab/pipeline/jobs/func-v12-php8.4-highest.yml
 create mode 100644 .gitlab/pipeline/jobs/func-v12-php8.4-lowest.yml
 create mode 100644 .gitlab/pipeline/jobs/php-lint-php8.4.yml
 create mode 100644 .gitlab/pipeline/jobs/unit-v12-php8.4-highest.yml

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4897eba..f167a8a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -44,6 +44,7 @@ jobs:
           - "8.1"
           - "8.2"
           - "8.3"
+          - "8.4"
   code-quality:
     name: "Code quality checks"
     runs-on: ubuntu-24.04
@@ -174,6 +175,12 @@ jobs:
           - typo3-version: "^12.4"
             php-version: "8.3"
             composer-dependencies: highest
+          - typo3-version: "^12.4"
+            php-version: "8.4"
+            composer-dependencies: lowest
+          - typo3-version: "^12.4"
+            php-version: "8.4"
+            composer-dependencies: highest
   functional-tests:
     name: "Functional tests"
     runs-on: ubuntu-24.04
@@ -251,6 +258,12 @@ jobs:
           - typo3-version: "^12.4"
             php-version: "8.3"
             composer-dependencies: highest
+#          - typo3-version: "^12.4"
+#            php-version: "8.4"
+#            composer-dependencies: lowest
+          - typo3-version: "^12.4"
+            php-version: "8.4"
+            composer-dependencies: highest
   shellcheck:
     name: Check shell scripts
     runs-on: ubuntu-24.04
diff --git a/.gitlab/pipeline/.gitlab-ci.yml b/.gitlab/pipeline/.gitlab-ci.yml
index b2e768e..f4b8cac 100644
--- a/.gitlab/pipeline/.gitlab-ci.yml
+++ b/.gitlab/pipeline/.gitlab-ci.yml
@@ -20,6 +20,8 @@ include:
   - '/.gitlab/pipeline/jobs/func-v12-php8.2-lowest.yml'
   - '/.gitlab/pipeline/jobs/func-v12-php8.3-highest.yml'
   - '/.gitlab/pipeline/jobs/func-v12-php8.3-lowest.yml'
+  - '/.gitlab/pipeline/jobs/func-v12-php8.4-highest.yml'
+  - '/.gitlab/pipeline/jobs/func-v12-php8.4-lowest.yml'
   - '/.gitlab/pipeline/jobs/javascript-lint.yml'
   - '/.gitlab/pipeline/jobs/json-lint.yml'
   - '/.gitlab/pipeline/jobs/php-cs-fixer.yml'
@@ -34,6 +36,7 @@ include:
   - '/.gitlab/pipeline/jobs/unit-v12-php8.2-lowest.yml'
   - '/.gitlab/pipeline/jobs/unit-v12-php8.3-highest.yml'
   - '/.gitlab/pipeline/jobs/unit-v12-php8.3-lowest.yml'
+  - '/.gitlab/pipeline/jobs/unit-v12-php8.4-highest.yml'
   - '/.gitlab/pipeline/jobs/xliff-lint.yml'
   - '/.gitlab/pipeline/jobs/yaml-lint.yml'
   - template: Security/Secret-Detection.gitlab-ci.yml
diff --git a/.gitlab/pipeline/jobs/func-v12-php8.4-highest.yml b/.gitlab/pipeline/jobs/func-v12-php8.4-highest.yml
new file mode 100644
index 0000000..f219893
--- /dev/null
+++ b/.gitlab/pipeline/jobs/func-v12-php8.4-highest.yml
@@ -0,0 +1,14 @@
+func-v12-php8.4-highest:
+  extends: .default
+  image: ghcr.io/typo3/core-testing-php84:latest
+  services:
+    - mariadb:10
+  stage: test
+  needs:
+    - build-composer-dependencies
+    - php-lint-php8.4
+  script:
+    - echo "Job ${CI_JOB_NAME}"
+    - composer require --no-ansi --no-interaction --no-progress --no-install typo3/cms-core:"^12.4"
+    - composer update --no-ansi --no-interaction --no-progress --with-dependencies
+    - composer ci:tests:functional
diff --git a/.gitlab/pipeline/jobs/func-v12-php8.4-lowest.yml b/.gitlab/pipeline/jobs/func-v12-php8.4-lowest.yml
new file mode 100644
index 0000000..e5f0058
--- /dev/null
+++ b/.gitlab/pipeline/jobs/func-v12-php8.4-lowest.yml
@@ -0,0 +1,14 @@
+func-v12-php8.4-lowest:
+  extends: .default
+  image: ghcr.io/typo3/core-testing-php84:latest
+  services:
+    - mariadb:10
+  stage: test
+  needs:
+    - build-composer-dependencies
+    - php-lint-php8.4
+  script:
+    - echo "Job ${CI_JOB_NAME}"
+    - composer require --no-ansi --no-interaction --no-progress --no-install typo3/cms-core:"^12.4"
+    - composer update --no-ansi --no-interaction --no-progress --with-dependencies --prefer-lowest
+    - composer ci:tests:functional
diff --git a/.gitlab/pipeline/jobs/php-lint-php8.4.yml b/.gitlab/pipeline/jobs/php-lint-php8.4.yml
new file mode 100644
index 0000000..a9724eb
--- /dev/null
+++ b/.gitlab/pipeline/jobs/php-lint-php8.4.yml
@@ -0,0 +1,7 @@
+php-lint-php8.4:
+  extends: .composer-update
+  image: ghcr.io/typo3/core-testing-php84:latest
+  stage: lint
+  needs: [ ]
+  script:
+    - composer ci:php:lint
diff --git a/.gitlab/pipeline/jobs/unit-v12-php8.4-highest.yml b/.gitlab/pipeline/jobs/unit-v12-php8.4-highest.yml
new file mode 100644
index 0000000..c61e3b9
--- /dev/null
+++ b/.gitlab/pipeline/jobs/unit-v12-php8.4-highest.yml
@@ -0,0 +1,11 @@
+unit-v12-php8.4-highest:
+  extends: .default
+  image: ghcr.io/typo3/core-testing-php84:latest
+  stage: test
+  needs:
+    - build-composer-dependencies
+    - php-lint-php8.4
+  script:
+    - echo "Job ${CI_JOB_NAME}"
+    - composer require --no-progress typo3/cms-core:"^12.4"
+    - composer ci:tests:unit
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f1807e..46e4d73 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
 ## x.y.z
 
 ### Added
+- Add support for PHP 8.4 (#1536)
 - Add support for PostgreSQL 16 (#1271)
 
 ### Changed
diff --git a/composer.json b/composer.json
index b0113fa..36aa278 100644
--- a/composer.json
+++ b/composer.json
@@ -39,7 +39,7 @@
 		"docs": "https://docs.typo3.org/p/ttn/tea/main/en-us/"
 	},
 	"require": {
-		"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
+		"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
 		"psr/http-message": "^1.0.1",
 		"typo3/cms-core": "^12.4.26",
 		"typo3/cms-extbase": "^12.4.26",
diff --git a/ext_emconf.php b/ext_emconf.php
index aca4b50..ad93ded 100644
--- a/ext_emconf.php
+++ b/ext_emconf.php
@@ -7,7 +7,7 @@ $EM_CONF[$_EXTKEY] = [
     'category' => 'example',
     'constraints' => [
         'depends' => [
-            'php' => '8.1.0-8.3.99',
+            'php' => '8.1.0-8.4.99',
             'typo3' => '12.4.26-12.4.99',
             'extbase' => '12.4.26-12.4.99',
             'fluid' => '12.4.26-12.4.99',
diff --git a/rector.php b/rector.php
index ba12c0e..7f171a9 100644
--- a/rector.php
+++ b/rector.php
@@ -94,7 +94,7 @@ return RectorConfig::configure()
     ])
     ->withImportNames(true, true, false)
     ->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.26-12.4.99',
         ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [],
     ])