From 05ecd5b0171978d9329248ffbab271bfc77d94a8 Mon Sep 17 00:00:00 2001
From: Daniel Goerz <daniel.goerz@posteo.de>
Date: Tue, 4 May 2021 18:41:24 +0200
Subject: [PATCH] [TASK] Enable phpstan parameter checkPhpDocMethodSignatures

Resolves: #94059
Releases: master
Change-Id: I9687dddef9889d79359e64987e8886a305d3149f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69016
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
---
 Build/phpstan.level3.neon                              |  2 +-
 phpstan.neon                                           | 10 ++++++++++
 .../Classes/Collection/AbstractRecordCollection.php    |  4 ++--
 .../Security/FileMetadataPermissionsAspect.php         |  2 +-
 .../extbase/Classes/Persistence/Generic/Query.php      |  4 ++--
 .../Classes/Linktype/LinktypeInterface.php             |  2 +-
 6 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/Build/phpstan.level3.neon b/Build/phpstan.level3.neon
index 7eca0f571784..16e002b348ce 100644
--- a/Build/phpstan.level3.neon
+++ b/Build/phpstan.level3.neon
@@ -15,7 +15,7 @@ rules:
 	- PHPStan\Rules\Variables\VariableCloningRule
 
 parameters:
-	checkPhpDocMethodSignatures: false # todo: set to true
+	checkPhpDocMethodSignatures: true
 
 services:
 	-
diff --git a/phpstan.neon b/phpstan.neon
index 601521d20152..26e7edd40cea 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -103,6 +103,16 @@ parameters:
       count: 1
       path: typo3/sysext/belog/Classes/Domain/Model/LogEntry.php
 
+    # checkPhpDocMethodSignatures
+    -
+      message: "#^Return type \\(TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\Expression\\\\ExpressionBuilder\\) of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Connection\\:\\:getExpressionBuilder\\(\\) should be compatible with return type \\(Doctrine\\\\DBAL\\\\Query\\\\Expression\\\\ExpressionBuilder\\) of method Doctrine\\\\DBAL\\\\Connection\\:\\:getExpressionBuilder\\(\\)$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Database/Connection.php
+    -
+      message: "#^Return type \\(TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\QueryBuilder\\) of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Connection\\:\\:createQueryBuilder\\(\\) should be compatible with return type \\(Doctrine\\\\DBAL\\\\Query\\\\QueryBuilder\\) of method Doctrine\\\\DBAL\\\\Connection\\:\\:createQueryBuilder\\(\\)$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Database/Connection.php
+
     # Ignored errors for level 4
     -
       message: "#^Ternary operator condition is always false\\.$#"
diff --git a/typo3/sysext/core/Classes/Collection/AbstractRecordCollection.php b/typo3/sysext/core/Classes/Collection/AbstractRecordCollection.php
index 5140bebb6e4b..5c5d95f95d8d 100644
--- a/typo3/sysext/core/Classes/Collection/AbstractRecordCollection.php
+++ b/typo3/sysext/core/Classes/Collection/AbstractRecordCollection.php
@@ -119,12 +119,12 @@ abstract class AbstractRecordCollection implements RecordCollectionInterface, Pe
      * Return the key of the current element
      *
      * @link https://php.net/manual/en/iterator.key.php
-     * @return int 0 on failure.
+     * @return int|string 0 on failure.
      */
     public function key()
     {
         $currentRecord = $this->storage->current();
-        return $currentRecord['uid'];
+        return $currentRecord['uid'] ?? 0;
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php b/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php
index b05e4b522f50..e73eecb37b31 100644
--- a/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php
+++ b/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php
@@ -59,7 +59,7 @@ class FileMetadataPermissionsAspect implements DataHandlerCheckModifyAccessListH
      * We "abuse" it here to actually check if access is allowed to sys_file_metadata.
      *
      *
-     * @param int $accessAllowed Whether the user has access to modify a table
+     * @param bool $accessAllowed Whether the user has access to modify a table
      * @param string $table The name of the table to be modified
      * @param DataHandler $parent The calling parent object
      * @throws \UnexpectedValueException
diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Query.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Query.php
index 572d941318e8..70f3d7b8af3e 100644
--- a/typo3/sysext/extbase/Classes/Persistence/Generic/Query.php
+++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Query.php
@@ -96,7 +96,7 @@ class Query implements QueryInterface
     protected $statement;
 
     /**
-     * @var int[]
+     * @var array<string, string>
      */
     protected $orderings = [];
 
@@ -294,7 +294,7 @@ class Query implements QueryInterface
      * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
      * )
      *
-     * @return int
+     * @return array<string, string>
      */
     public function getOrderings()
     {
diff --git a/typo3/sysext/linkvalidator/Classes/Linktype/LinktypeInterface.php b/typo3/sysext/linkvalidator/Classes/Linktype/LinktypeInterface.php
index b29689fcd73f..3c3a322d2d56 100644
--- a/typo3/sysext/linkvalidator/Classes/Linktype/LinktypeInterface.php
+++ b/typo3/sysext/linkvalidator/Classes/Linktype/LinktypeInterface.php
@@ -26,7 +26,7 @@ interface LinktypeInterface
      * @param string $url Url to check
      * @param array $softRefEntry The soft reference entry which builds the context of that url
      * @param \TYPO3\CMS\Linkvalidator\LinkAnalyzer $reference Parent instance
-     * @return string Validation error message or success code
+     * @return bool TRUE on success or FALSE on error
      */
     public function checkLink($url, $softRefEntry, $reference);
 
-- 
GitLab