From d680c00572740f901dac4e04487c5965b241076c Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Sat, 10 Feb 2024 18:07:53 +0100 Subject: [PATCH 1/4] TASK: Run rector rule set SetList::PHP_55 --- Classes/Database/DatabaseConnection.php | 28 ++++++++++--------- .../PostProcessQueryHookInterface.php | 24 ++++++++-------- .../Database/PreProcessQueryHookInterface.php | 24 ++++++++-------- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/Classes/Database/DatabaseConnection.php b/Classes/Database/DatabaseConnection.php index b1178b6..93f8bf9 100644 --- a/Classes/Database/DatabaseConnection.php +++ b/Classes/Database/DatabaseConnection.php @@ -13,7 +13,9 @@ * * The TYPO3 project - inspiring people to share! */ - +use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Exception\ConnectionException; +use TYPO3\CMS\Core\Utility\DebugUtility; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Query\QueryHelper; @@ -802,14 +804,14 @@ public function searchQuery($searchWords, $fields, $table, $constraint = self::A * @param string $orderBy See exec_SELECTquery() * @param string $limit See exec_SELECTquery() * @param array $input_parameters An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement::PARAM_AUTOTYPE. - * @return \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement Prepared statement + * @return PreparedStatement Prepared statement */ public function prepare_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '', array $input_parameters = []) { $this->logDeprecation(); $query = $this->SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit); /** @var $preparedStatement \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement */ - $preparedStatement = GeneralUtility::makeInstance(\TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement::class, $query, $from_table, []); + $preparedStatement = GeneralUtility::makeInstance(PreparedStatement::class, $query, $from_table, []); // Bind values to parameters foreach ($input_parameters as $key => $value) { $preparedStatement->bindValue($key, $value, PreparedStatement::PARAM_AUTOTYPE); @@ -823,7 +825,7 @@ public function prepare_SELECTquery($select_fields, $from_table, $where_clause, * * @param array $queryParts Query parts array * @param array $input_parameters An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement::PARAM_AUTOTYPE. - * @return \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement Prepared statement + * @return PreparedStatement Prepared statement */ public function prepare_SELECTqueryArray(array $queryParts, array $input_parameters = []) { @@ -1289,7 +1291,7 @@ public function sql_pconnect() // We are not using the TYPO3 CMS shim here as the database parameters in this class // are settable externally. This requires building the connection parameter array // just in time when establishing the connection. - $connection = \Doctrine\DBAL\DriverManager::getConnection([ + $connection = DriverManager::getConnection([ 'driver' => 'mysqli', 'wrapperClass' => Connection::class, 'host' => $host, @@ -1305,7 +1307,7 @@ public function sql_pconnect() /** @var \Doctrine\DBAL\Driver\Mysqli\MysqliConnection $mysqliConnection */ $mysqliConnection = $connection->getWrappedConnection(); $this->link = $mysqliConnection->getWrappedResourceHandle(); - } catch (\Doctrine\DBAL\Exception\ConnectionException $exception) { + } catch (ConnectionException $exception) { return false; } @@ -1836,12 +1838,12 @@ public function debug($func, $query = '') $this->logDeprecation(); $error = $this->sql_error(); if ($error || (int)$this->debugOutput === 2) { - \TYPO3\CMS\Core\Utility\DebugUtility::debug( + DebugUtility::debug( [ 'caller' => \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection::class . '::' . $func, 'ERROR' => $error, - 'lastBuiltQuery' => $query ? $query : $this->debug_lastBuiltQuery, - 'debug_backtrace' => \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail() + 'lastBuiltQuery' => $query ?: $this->debug_lastBuiltQuery, + 'debug_backtrace' => DebugUtility::debugTrail() ], $func, is_object($GLOBALS['error']) && @is_callable([$GLOBALS['error'], 'debug']) @@ -1914,7 +1916,7 @@ protected function explain($query, $from_table, $row_count) return false; } $error = $this->sql_error(); - $trail = \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail(); + $trail = DebugUtility::debugTrail(); $explain_tables = []; $explain_output = []; $res = $this->sql_query('EXPLAIN ' . $query, $this->link); @@ -1963,7 +1965,7 @@ protected function explain($query, $from_table, $row_count) $data['indices'] = $indices_output; } if ($explainMode == 1) { - \TYPO3\CMS\Core\Utility\DebugUtility::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN'); + DebugUtility::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN'); } elseif ($explainMode == 2) { /** @var TimeTracker $timeTracker */ $timeTracker = GeneralUtility::makeInstance(TimeTracker::class); @@ -2021,7 +2023,7 @@ protected function logError($message) GeneralUtility::SYSLOG_SEVERITY_ERROR ); } else { - GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)->error($message); + GeneralUtility::makeInstance(LogManager::class)->getLogger(self::class)->error($message); } } @@ -2034,7 +2036,7 @@ protected function logFatalError($message) GeneralUtility::SYSLOG_SEVERITY_FATAL ); } else { - GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)->emergency($message); + GeneralUtility::makeInstance(LogManager::class)->getLogger(self::class)->emergency($message); } } } diff --git a/Classes/Database/PostProcessQueryHookInterface.php b/Classes/Database/PostProcessQueryHookInterface.php index f6e7a1f..da12035 100644 --- a/Classes/Database/PostProcessQueryHookInterface.php +++ b/Classes/Database/PostProcessQueryHookInterface.php @@ -29,9 +29,9 @@ interface PostProcessQueryHookInterface * @param string $groupBy Group by statement * @param string $orderBy Order by statement * @param int $limit Database return limit - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function exec_SELECTquery_postProcessAction(&$select_fields, &$from_table, &$where_clause, &$groupBy, &$orderBy, &$limit, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function exec_SELECTquery_postProcessAction(&$select_fields, &$from_table, &$where_clause, &$groupBy, &$orderBy, &$limit, DatabaseConnection $parentObject); /** * Post-processor for the exec_INSERTquery method. @@ -39,9 +39,9 @@ public function exec_SELECTquery_postProcessAction(&$select_fields, &$from_table * @param string $table Database table name * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function exec_INSERTquery_postProcessAction(&$table, array &$fieldsValues, &$noQuoteFields, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function exec_INSERTquery_postProcessAction(&$table, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); /** * Post-processor for the exec_INSERTmultipleRows method. @@ -50,9 +50,9 @@ public function exec_INSERTquery_postProcessAction(&$table, array &$fieldsValues * @param array $fields Field names * @param array $rows Table rows * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function exec_INSERTmultipleRows_postProcessAction(&$table, array &$fields, array &$rows, &$noQuoteFields, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function exec_INSERTmultipleRows_postProcessAction(&$table, array &$fields, array &$rows, &$noQuoteFields, DatabaseConnection $parentObject); /** * Post-processor for the exec_UPDATEquery method. @@ -61,24 +61,24 @@ public function exec_INSERTmultipleRows_postProcessAction(&$table, array &$field * @param string $where WHERE clause * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function exec_UPDATEquery_postProcessAction(&$table, &$where, array &$fieldsValues, &$noQuoteFields, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function exec_UPDATEquery_postProcessAction(&$table, &$where, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); /** * Post-processor for the exec_DELETEquery method. * * @param string $table Database table name * @param string $where WHERE clause - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function exec_DELETEquery_postProcessAction(&$table, &$where, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function exec_DELETEquery_postProcessAction(&$table, &$where, DatabaseConnection $parentObject); /** * Post-processor for the exec_TRUNCATEquery method. * * @param string $table Database table name - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function exec_TRUNCATEquery_postProcessAction(&$table, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function exec_TRUNCATEquery_postProcessAction(&$table, DatabaseConnection $parentObject); } diff --git a/Classes/Database/PreProcessQueryHookInterface.php b/Classes/Database/PreProcessQueryHookInterface.php index 15fc383..854cd33 100644 --- a/Classes/Database/PreProcessQueryHookInterface.php +++ b/Classes/Database/PreProcessQueryHookInterface.php @@ -29,9 +29,9 @@ interface PreProcessQueryHookInterface * @param string $groupBy Group by statement * @param string $orderBy Order by statement * @param int $limit Database return limit - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function SELECTquery_preProcessAction(&$select_fields, &$from_table, &$where_clause, &$groupBy, &$orderBy, &$limit, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function SELECTquery_preProcessAction(&$select_fields, &$from_table, &$where_clause, &$groupBy, &$orderBy, &$limit, DatabaseConnection $parentObject); /** * Pre-processor for the INSERTquery method. @@ -39,9 +39,9 @@ public function SELECTquery_preProcessAction(&$select_fields, &$from_table, &$wh * @param string $table Database table name * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function INSERTquery_preProcessAction(&$table, array &$fieldsValues, &$noQuoteFields, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function INSERTquery_preProcessAction(&$table, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); /** * Pre-processor for the INSERTmultipleRows method. @@ -52,9 +52,9 @@ public function INSERTquery_preProcessAction(&$table, array &$fieldsValues, &$no * @param array $fields Field names * @param array $rows Table rows * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function INSERTmultipleRows_preProcessAction(&$table, array &$fields, array &$rows, &$noQuoteFields, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function INSERTmultipleRows_preProcessAction(&$table, array &$fields, array &$rows, &$noQuoteFields, DatabaseConnection $parentObject); /** * Pre-processor for the UPDATEquery method. @@ -63,24 +63,24 @@ public function INSERTmultipleRows_preProcessAction(&$table, array &$fields, arr * @param string $where WHERE clause * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function UPDATEquery_preProcessAction(&$table, &$where, array &$fieldsValues, &$noQuoteFields, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function UPDATEquery_preProcessAction(&$table, &$where, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); /** * Pre-processor for the DELETEquery method. * * @param string $table Database table name * @param string $where WHERE clause - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function DELETEquery_preProcessAction(&$table, &$where, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function DELETEquery_preProcessAction(&$table, &$where, DatabaseConnection $parentObject); /** * Pre-processor for the TRUNCATEquery method. * * @param string $table Database table name - * @param \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject + * @param DatabaseConnection $parentObject */ - public function TRUNCATEquery_preProcessAction(&$table, \TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection $parentObject); + public function TRUNCATEquery_preProcessAction(&$table, DatabaseConnection $parentObject); } From 53069fc76043d50a893227854a51d684a0fab431 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Sat, 10 Feb 2024 18:10:06 +0100 Subject: [PATCH 2/4] TASK: Run rector rule set SetList::PHP_71 --- Classes/Database/DatabaseConnection.php | 17 +++++++---------- Classes/Database/PreparedStatement.php | 14 +++++++------- ext_localconf.php | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Classes/Database/DatabaseConnection.php b/Classes/Database/DatabaseConnection.php index 93f8bf9..1802fa9 100644 --- a/Classes/Database/DatabaseConnection.php +++ b/Classes/Database/DatabaseConnection.php @@ -59,14 +59,14 @@ class DatabaseConnection * * @var string */ - const AND_Constraint = 'AND'; + public const AND_Constraint = 'AND'; /** * The OR constraint in where clause * * @var string */ - const OR_Constraint = 'OR'; + public const OR_Constraint = 'OR'; /** * Set "TRUE" or "1" if you want database errors outputted. Set to "2" if you also want successful database actions outputted. @@ -447,7 +447,7 @@ public function exec_SELECTcountRows($field, $table, $where = '1=1') $count = false; $resultSet = $this->exec_SELECTquery('COUNT(' . $field . ')', $table, $where); if ($resultSet !== false) { - list($count) = $this->sql_fetch_row($resultSet); + [$count] = $this->sql_fetch_row($resultSet); $count = (int)$count; $this->sql_free_result($resultSet); } @@ -1845,10 +1845,7 @@ public function debug($func, $query = '') 'lastBuiltQuery' => $query ?: $this->debug_lastBuiltQuery, 'debug_backtrace' => DebugUtility::debugTrail() ], - $func, - is_object($GLOBALS['error']) && @is_callable([$GLOBALS['error'], 'debug']) - ? '' - : 'DB Error' + $func ); } } @@ -1919,7 +1916,7 @@ protected function explain($query, $from_table, $row_count) $trail = DebugUtility::debugTrail(); $explain_tables = []; $explain_output = []; - $res = $this->sql_query('EXPLAIN ' . $query, $this->link); + $res = $this->sql_query('EXPLAIN ' . $query); if (is_a($res, '\\mysqli_result')) { while ($tempRow = $this->sql_fetch_assoc($res)) { $explain_output[] = $tempRow; @@ -1936,7 +1933,7 @@ protected function explain($query, $from_table, $row_count) $tableRes = $this->sql_query('SHOW TABLE STATUS LIKE \'' . $table . '\''); $isTable = $this->sql_num_rows($tableRes); if ($isTable) { - $res = $this->sql_query('SHOW INDEX FROM ' . $table, $this->link); + $res = $this->sql_query('SHOW INDEX FROM ' . $table); if (is_a($res, '\\mysqli_result')) { while ($tempRow = $this->sql_fetch_assoc($res)) { $indices_output[] = $tempRow; @@ -1965,7 +1962,7 @@ protected function explain($query, $from_table, $row_count) $data['indices'] = $indices_output; } if ($explainMode == 1) { - DebugUtility::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN'); + DebugUtility::debug($data, 'Tables: ' . $from_table); } elseif ($explainMode == 2) { /** @var TimeTracker $timeTracker */ $timeTracker = GeneralUtility::makeInstance(TimeTracker::class); diff --git a/Classes/Database/PreparedStatement.php b/Classes/Database/PreparedStatement.php index 52dd6ff..9488d6d 100644 --- a/Classes/Database/PreparedStatement.php +++ b/Classes/Database/PreparedStatement.php @@ -42,35 +42,35 @@ class PreparedStatement * * @var int */ - const PARAM_NULL = 0; + public const PARAM_NULL = 0; /** * Represents the SQL INTEGER data type. * * @var int */ - const PARAM_INT = 1; + public const PARAM_INT = 1; /** * Represents the SQL CHAR, VARCHAR, or other string data type. * * @var int */ - const PARAM_STR = 2; + public const PARAM_STR = 2; /** * Represents a boolean data type. * * @var int */ - const PARAM_BOOL = 3; + public const PARAM_BOOL = 3; /** * Automatically detects underlying type * * @var int */ - const PARAM_AUTOTYPE = 4; + public const PARAM_AUTOTYPE = 4; /** * Specifies that the fetch method shall return each row as an array indexed by @@ -80,7 +80,7 @@ class PreparedStatement * * @var int */ - const FETCH_ASSOC = 2; + public const FETCH_ASSOC = 2; /** * Specifies that the fetch method shall return each row as an array indexed by @@ -88,7 +88,7 @@ class PreparedStatement * * @var int */ - const FETCH_NUM = 3; + public const FETCH_NUM = 3; /** * Query to be executed. diff --git a/ext_localconf.php b/ext_localconf.php index 8c5f6c4..8dc36d9 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -26,7 +26,7 @@ $databaseConnection->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['port']); } elseif (strpos($databaseHost, ':') > 0) { // @TODO: Find a way to handle this case in the install tool and drop this - list($databaseHost, $databasePort) = explode(':', $databaseHost); + [$databaseHost, $databasePort] = explode(':', $databaseHost); $databaseConnection->setDatabasePort($databasePort); } if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['unix_socket'])) { From 2c623f2c48e7c7db4d2411caf7797a123af075dc Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Sat, 10 Feb 2024 18:16:49 +0100 Subject: [PATCH 3/4] TASK: Run rector rule set SetList::PHP_80 --- Classes/Database/DatabaseConnection.php | 17 +++---- .../PostProcessQueryHookInterface.php | 6 --- .../Database/PreProcessQueryHookInterface.php | 6 --- Classes/Database/PreparedStatement.php | 46 ++++++------------- 4 files changed, 21 insertions(+), 54 deletions(-) diff --git a/Classes/Database/DatabaseConnection.php b/Classes/Database/DatabaseConnection.php index 1802fa9..715fde7 100644 --- a/Classes/Database/DatabaseConnection.php +++ b/Classes/Database/DatabaseConnection.php @@ -751,7 +751,7 @@ public function listQuery($field, $value, $table) { $this->logDeprecation(); $value = (string)$value; - if (strpos($value, ',') !== false) { + if (str_contains($value, ',')) { throw new \InvalidArgumentException('$value must not contain a comma (,) in $this->listQuery() !', 1294585862); } $pattern = $this->quoteStr($value, $table); @@ -771,13 +771,10 @@ public function listQuery($field, $value, $table) public function searchQuery($searchWords, $fields, $table, $constraint = self::AND_Constraint) { $this->logDeprecation(); - switch ($constraint) { - case self::OR_Constraint: - $constraint = 'OR'; - break; - default: - $constraint = 'AND'; - } + $constraint = match ($constraint) { + self::OR_Constraint => 'OR', + default => 'AND', + }; $queryParts = []; foreach ($searchWords as $sw) { @@ -1307,7 +1304,7 @@ public function sql_pconnect() /** @var \Doctrine\DBAL\Driver\Mysqli\MysqliConnection $mysqliConnection */ $mysqliConnection = $connection->getWrappedConnection(); $this->link = $mysqliConnection->getWrappedResourceHandle(); - } catch (ConnectionException $exception) { + } catch (ConnectionException) { return false; } @@ -1383,7 +1380,7 @@ public function admin_get_dbs() if ($this->sql_select_db()) { $dbArr[] = $row->SCHEMA_NAME; } - } catch (\RuntimeException $exception) { + } catch (\RuntimeException) { // The exception happens if we cannot connect to the database // (usually due to missing permissions). This is ok here. // We catch the exception, skip the database and continue. diff --git a/Classes/Database/PostProcessQueryHookInterface.php b/Classes/Database/PostProcessQueryHookInterface.php index da12035..996eb3a 100644 --- a/Classes/Database/PostProcessQueryHookInterface.php +++ b/Classes/Database/PostProcessQueryHookInterface.php @@ -29,7 +29,6 @@ interface PostProcessQueryHookInterface * @param string $groupBy Group by statement * @param string $orderBy Order by statement * @param int $limit Database return limit - * @param DatabaseConnection $parentObject */ public function exec_SELECTquery_postProcessAction(&$select_fields, &$from_table, &$where_clause, &$groupBy, &$orderBy, &$limit, DatabaseConnection $parentObject); @@ -39,7 +38,6 @@ public function exec_SELECTquery_postProcessAction(&$select_fields, &$from_table * @param string $table Database table name * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param DatabaseConnection $parentObject */ public function exec_INSERTquery_postProcessAction(&$table, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); @@ -50,7 +48,6 @@ public function exec_INSERTquery_postProcessAction(&$table, array &$fieldsValues * @param array $fields Field names * @param array $rows Table rows * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param DatabaseConnection $parentObject */ public function exec_INSERTmultipleRows_postProcessAction(&$table, array &$fields, array &$rows, &$noQuoteFields, DatabaseConnection $parentObject); @@ -61,7 +58,6 @@ public function exec_INSERTmultipleRows_postProcessAction(&$table, array &$field * @param string $where WHERE clause * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param DatabaseConnection $parentObject */ public function exec_UPDATEquery_postProcessAction(&$table, &$where, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); @@ -70,7 +66,6 @@ public function exec_UPDATEquery_postProcessAction(&$table, &$where, array &$fie * * @param string $table Database table name * @param string $where WHERE clause - * @param DatabaseConnection $parentObject */ public function exec_DELETEquery_postProcessAction(&$table, &$where, DatabaseConnection $parentObject); @@ -78,7 +73,6 @@ public function exec_DELETEquery_postProcessAction(&$table, &$where, DatabaseCon * Post-processor for the exec_TRUNCATEquery method. * * @param string $table Database table name - * @param DatabaseConnection $parentObject */ public function exec_TRUNCATEquery_postProcessAction(&$table, DatabaseConnection $parentObject); } diff --git a/Classes/Database/PreProcessQueryHookInterface.php b/Classes/Database/PreProcessQueryHookInterface.php index 854cd33..a23d987 100644 --- a/Classes/Database/PreProcessQueryHookInterface.php +++ b/Classes/Database/PreProcessQueryHookInterface.php @@ -29,7 +29,6 @@ interface PreProcessQueryHookInterface * @param string $groupBy Group by statement * @param string $orderBy Order by statement * @param int $limit Database return limit - * @param DatabaseConnection $parentObject */ public function SELECTquery_preProcessAction(&$select_fields, &$from_table, &$where_clause, &$groupBy, &$orderBy, &$limit, DatabaseConnection $parentObject); @@ -39,7 +38,6 @@ public function SELECTquery_preProcessAction(&$select_fields, &$from_table, &$wh * @param string $table Database table name * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param DatabaseConnection $parentObject */ public function INSERTquery_preProcessAction(&$table, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); @@ -52,7 +50,6 @@ public function INSERTquery_preProcessAction(&$table, array &$fieldsValues, &$no * @param array $fields Field names * @param array $rows Table rows * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param DatabaseConnection $parentObject */ public function INSERTmultipleRows_preProcessAction(&$table, array &$fields, array &$rows, &$noQuoteFields, DatabaseConnection $parentObject); @@ -63,7 +60,6 @@ public function INSERTmultipleRows_preProcessAction(&$table, array &$fields, arr * @param string $where WHERE clause * @param array $fieldsValues Field values as key => value pairs * @param string|array $noQuoteFields List/array of keys NOT to quote - * @param DatabaseConnection $parentObject */ public function UPDATEquery_preProcessAction(&$table, &$where, array &$fieldsValues, &$noQuoteFields, DatabaseConnection $parentObject); @@ -72,7 +68,6 @@ public function UPDATEquery_preProcessAction(&$table, &$where, array &$fieldsVal * * @param string $table Database table name * @param string $where WHERE clause - * @param DatabaseConnection $parentObject */ public function DELETEquery_preProcessAction(&$table, &$where, DatabaseConnection $parentObject); @@ -80,7 +75,6 @@ public function DELETEquery_preProcessAction(&$table, &$where, DatabaseConnectio * Pre-processor for the TRUNCATEquery method. * * @param string $table Database table name - * @param DatabaseConnection $parentObject */ public function TRUNCATEquery_preProcessAction(&$table, DatabaseConnection $parentObject); } diff --git a/Classes/Database/PreparedStatement.php b/Classes/Database/PreparedStatement.php index 9488d6d..86e3b59 100644 --- a/Classes/Database/PreparedStatement.php +++ b/Classes/Database/PreparedStatement.php @@ -90,13 +90,6 @@ class PreparedStatement */ public const FETCH_NUM = 3; - /** - * Query to be executed. - * - * @var string - */ - protected $query; - /** * Components of the query to be executed. * @@ -104,13 +97,6 @@ class PreparedStatement */ protected $precompiledQueryParts; - /** - * Table (used to call $GLOBALS['TYPO3_DB']->fullQuoteStr(). - * - * @var string - */ - protected $table; - /** * Binding parameters. * @@ -165,20 +151,24 @@ class PreparedStatement * @access private * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, use Doctrine DBAL as it does PreparedStatements built-in */ - public function __construct($query, $table, array $precompiledQueryParts = []) + public function __construct(/** + * Query to be executed. + */ + protected $query, /** + * Table (used to call $GLOBALS['TYPO3_DB']->fullQuoteStr(). + */ + protected $table, array $precompiledQueryParts = []) { if (method_exists('GeneralUtility', 'logDeprecatedFunction')) { GeneralUtility::logDeprecatedFunction(); } else { trigger_error('PreparedStatement from EXT:typo3db_legacy is marked as deprecated, use Doctrine DBAL as it does PreparedStatements built-in', E_USER_DEPRECATED); } - $this->query = $query; $this->precompiledQueryParts = $precompiledQueryParts; - $this->table = $table; $this->parameters = []; // Test if named placeholders are used - if ($this->hasNamedPlaceholders($query) || !empty($precompiledQueryParts)) { + if ($this->hasNamedPlaceholders($this->query) || !empty($precompiledQueryParts)) { $this->statement = null; } else { // Only question mark placeholders are used @@ -241,7 +231,7 @@ public function bindValues(array $values) * @return \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement The current prepared statement to allow method chaining * @api */ - public function bindValue($parameter, $value, $data_type = self::PARAM_AUTOTYPE) + public function bindValue(mixed $parameter, mixed $value, $data_type = self::PARAM_AUTOTYPE) { switch ($data_type) { case self::PARAM_INT: @@ -556,23 +546,18 @@ public function errorInfo() */ public function setFetchMode($mode) { - switch ($mode) { - case self::FETCH_ASSOC: - case self::FETCH_NUM: - $this->defaultFetchMode = $mode; - break; - default: - throw new \InvalidArgumentException('$mode must be either TYPO3\\CMS\\Typo3DbLegacy\\Database\\PreparedStatement::FETCH_ASSOC or TYPO3\\CMS\\Typo3DbLegacy\\Database\\PreparedStatement::FETCH_NUM', 1281875340); - } + $this->defaultFetchMode = match ($mode) { + self::FETCH_ASSOC, self::FETCH_NUM => $mode, + default => throw new \InvalidArgumentException('$mode must be either TYPO3\\CMS\\Typo3DbLegacy\\Database\\PreparedStatement::FETCH_ASSOC or TYPO3\\CMS\\Typo3DbLegacy\\Database\\PreparedStatement::FETCH_NUM', 1281875340), + }; } /** * Guesses the type of a given value. * - * @param mixed $value * @return int One of the \TYPO3\CMS\Typo3DbLegacy\Database\PreparedStatement::PARAM_* constants */ - protected function guessValueType($value) + protected function guessValueType(mixed $value) { if (is_bool($value)) { $type = self::PARAM_BOOL; @@ -602,8 +587,6 @@ protected function hasNamedPlaceholders($query) * Converts named placeholders into question mark placeholders in a query. * * @param string $query - * @param array $parameterValues - * @param array $precompiledQueryParts */ protected function convertNamedPlaceholdersToQuestionMarks(&$query, array &$parameterValues, array &$precompiledQueryParts) { @@ -656,7 +639,6 @@ protected function convertNamedPlaceholdersToQuestionMarks(&$query, array &$para * Replace the markers with unpredictable token markers. * * @param string $query - * @param array $parameterValues * @return string * @throws \InvalidArgumentException */ From 69130b259f87105ec1fd1e52ef6beb641f28c86c Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Sat, 10 Feb 2024 18:19:02 +0100 Subject: [PATCH 4/4] require PHP 8 as minimum --- composer.json | 3 ++- ext_emconf.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ee5b58..5cdf38e 100644 --- a/composer.json +++ b/composer.json @@ -8,9 +8,10 @@ "issues": "https://github.com/FriendsOfTYPO3/typo3db_legacy/issues", "source": "https://github.com/FriendsOfTYPO3/typo3db_legacy" }, - "license": ["GPL-2.0+"], + "license": ["GPL-2.0-or-later"], "require": { + "php": "^8.0", "typo3/cms-core": "^10.0 || ^11.0 || ^12.0" }, "extra": { diff --git a/ext_emconf.php b/ext_emconf.php index 31764c7..2a6aa4d 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -13,6 +13,7 @@ 'version' => '1.2.0', 'constraints' => [ 'depends' => [ + 'php' => '8.0.0-8.4.99', 'typo3' => '10.4.0-12.4.99', 'backend' => '10.4.0-12.4.99', ],