From 2b27de103d5aece89ea26fdc08a7c300a9abd99c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Sun, 2 Oct 2022 15:07:50 +0200
Subject: [PATCH] [!!!][TASK] Change method signatures and remove sanitization

This change tackle a left over @todo regarding method
changes related to strict typing of interface changes
for TYPO3 v12.0. Sanitization for null arguments is
removed along the way.

A unit test prophecy dealing with defaults needs
to be adjusted along the way.

Resolves: #98500
Related: #95794
Releases: main
Change-Id: Icb15ec42fbbc04840fa9d6459b1382348d57be96
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75939
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Kevin Appelt <kevin.appelt@icloud.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
---
 .../Database/Query/Expression/ExpressionBuilder.php        | 7 ++-----
 .../12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst | 1 +
 .../Database/Query/Expression/ExpressionBuilderTest.php    | 4 ++--
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php b/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php
index 6621ed48739c..8eb7f6474412 100644
--- a/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php
+++ b/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php
@@ -613,14 +613,11 @@ class ExpressionBuilder
      * Quotes a given input parameter.
      *
      * @param mixed $input The parameter to be quoted.
-     * @param string|int|null $type The type of the parameter.
+     * @param \PDO::PARAM_*|Connection::PARAM_*|int $type The type of the parameter.
      * @return mixed Often string, but also int or float or similar depending on $input and platform
-     * @todo: Change signature to literal($input, int $type = \PDO::PARAM_STR) as breaking change in v12.
      */
-    public function literal($input, $type = \PDO::PARAM_STR)
+    public function literal($input, int $type = \PDO::PARAM_STR)
     {
-        // @todo: drop this line together with signature change in v12
-        $type = $type ?? \PDO::PARAM_STR;
         return $this->connection->quote($input, $type);
     }
 
diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst
index 48654010325f..e8eda04a5316 100644
--- a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst
+++ b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst
@@ -206,6 +206,7 @@ The following PHP static class methods changed signature according to previous d
 
 The following PHP class methods changed signature according to previous deprecations in v11 and are now type hinted:
 
+- :php:`\TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder->literal()` (second argument requires an integer)
 - :php:`\TYPO3\CMS\Core\Database\Query\QueryBuilder->quote()` (second argument requires an integer)
 - :php:`\TYPO3\CMS\Core\TimeTracker\TimeTracker->setTSlogMessage()` (second argument requires a string)
 - :php:`\TYPO3\CMS\Backend\Tree\View\AbstractTreeView->getIcon()` (first argument is now type hinted `array`)
diff --git a/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php b/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php
index f2a5bee529bd..c5e0e4f3e2cc 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php
@@ -777,10 +777,10 @@ class ExpressionBuilderTest extends UnitTestCase
      */
     public function literalQuotesValue(): void
     {
-        $this->connectionProphecy->quote('aField', 'Doctrine\DBAL\Types\StringType')
+        $this->connectionProphecy->quote('aField', \PDO::PARAM_STR)
             ->shouldBeCalled()
             ->willReturn('"aField"');
-        $result = $this->subject->literal('aField', 'Doctrine\DBAL\Types\StringType');
+        $result = $this->subject->literal('aField');
 
         self::assertSame('"aField"', $result);
     }
-- 
GitLab