From 6bed3af2a27db004b98c353316c238708fdfed42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Fri, 2 Sep 2022 14:58:08 +0200
Subject: [PATCH] [TASK] Avoid unsolveable phpstan error for return-type
 mismatch

PHP8.1 introduced native return types to native methods
and interfaces, which crashes if they are not compatible.
As a workaround the introduced `#[\ReturnTypeWillChange]`
attribute can be used to mitigate this, which has been
used to mitigate quite some issues with it.

PHPStan has released a new version which fixes a bunch
of bugs, which detects more issues in core. These will
be addressed with the dedicated PHPStan raise patch #98246.
However, one issue cannot be solved or added to the baseline
and must be fixed beforehand. The reason is, that phpstan
also evaluates the PHPDoc return type.

This change uses the `#[\ReturnTypeWillChange]` attribute
to silence this as a backportable intermediate solution.

Resolves: #98251
Related: #98246
Releases: main, 11.5
Change-Id: I24e7d24e735d2dffbca0eca21de602c40f7e7d2a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75599
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../core/Classes/Resource/Collection/AbstractFileCollection.php  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/typo3/sysext/core/Classes/Resource/Collection/AbstractFileCollection.php b/typo3/sysext/core/Classes/Resource/Collection/AbstractFileCollection.php
index a894527ca44f..6f145982416d 100644
--- a/typo3/sysext/core/Classes/Resource/Collection/AbstractFileCollection.php
+++ b/typo3/sysext/core/Classes/Resource/Collection/AbstractFileCollection.php
@@ -79,6 +79,7 @@ abstract class AbstractFileCollection extends AbstractRecordCollection
      *
      * @return string
      */
+    #[\ReturnTypeWillChange]
     public function key()
     {
         /** @var File $currentRecord */
-- 
GitLab