From 90824844b8a0ed29fce3ebdbceed95c337542bde Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 Oct 2021 02:20:34 +0200 Subject: [PATCH 1/5] Fix PHP 8.1 deprecations on PDO_sqlsrv Signed-off-by: Alexander M. Turek --- ci/github/phpunit/pdo_sqlsrv.xml | 3 +++ ci/github/phpunit/sqlsrv.xml | 3 +++ lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/github/phpunit/pdo_sqlsrv.xml b/ci/github/phpunit/pdo_sqlsrv.xml index a593cb9e677..9b07ffbb322 100644 --- a/ci/github/phpunit/pdo_sqlsrv.xml +++ b/ci/github/phpunit/pdo_sqlsrv.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/sqlsrv.xml b/ci/github/phpunit/sqlsrv.xml index 2ce14a11210..3e8a50b78ae 100644 --- a/ci/github/phpunit/sqlsrv.xml +++ b/ci/github/phpunit/sqlsrv.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 5669ccc270e..6f5871e77e2 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -33,7 +33,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le break; } - return parent::bindParam($param, $variable, $type, $length, $driverOptions); + return parent::bindParam($param, $variable, $type, $length ?? 0, $driverOptions); } /** From 75fc143c5a0e54d617111fb7791cbf8559c7b2ea Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 Oct 2021 00:43:34 +0200 Subject: [PATCH 2/5] Fix deprecation on ExpressionBuilder::literal() with default type Signed-off-by: Alexander M. Turek --- lib/Doctrine/DBAL/Connection.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index d2f5b8a9bba..3db37244399 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -2083,9 +2083,9 @@ private function _bindTypedValues($stmt, array $params, array $types) * @param mixed $value The value to bind. * @param int|string|Type|null $type The type to bind (PDO or DBAL). * - * @return mixed[] [0] => the (escaped) value, [1] => the binding type. + * @return array{mixed, int} [0] => the (escaped) value, [1] => the binding type. */ - private function getBindingInfo($value, $type) + private function getBindingInfo($value, $type): array { if (is_string($type)) { $type = Type::getType($type); @@ -2095,7 +2095,7 @@ private function getBindingInfo($value, $type) $value = $type->convertToDatabaseValue($value, $this->getDatabasePlatform()); $bindingType = $type->getBindingType(); } else { - $bindingType = $type; + $bindingType = $type ?? ParameterType::STRING; } return [$value, $bindingType]; From 94f38a80524132472be06881051e15149630d3d2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 Oct 2021 01:26:00 +0200 Subject: [PATCH 3/5] Fix PHP 8.1 deprecations in OracleSchemaManager Signed-off-by: Alexander M. Turek --- lib/Doctrine/DBAL/Schema/OracleSchemaManager.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 5676f04c46c..223ae4e37ae 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -11,6 +11,7 @@ use function array_change_key_case; use function array_values; use function assert; +use function is_string; use function preg_match; use function sprintf; use function str_replace; @@ -101,7 +102,7 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null $keyName = strtolower($tableIndex['name']); $buffer = []; - if (strtolower($tableIndex['is_primary']) === 'p') { + if ($tableIndex['is_primary'] === 'P') { $keyName = 'primary'; $buffer['primary'] = true; $buffer['non_unique'] = false; @@ -141,7 +142,9 @@ protected function _getPortableTableColumnDefinition($tableColumn) } // Default values returned from database sometimes have trailing spaces. - $tableColumn['data_default'] = trim($tableColumn['data_default']); + if (is_string($tableColumn['data_default'])) { + $tableColumn['data_default'] = trim($tableColumn['data_default']); + } if ($tableColumn['data_default'] === '' || $tableColumn['data_default'] === 'NULL') { $tableColumn['data_default'] = null; From df384f3d6002741d31614dc13b854cdf84507e8a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 Oct 2021 23:44:30 +0200 Subject: [PATCH 4/5] Fix PHP 8.1 deprecations in PostgreSqlSchemaManager Signed-off-by: Alexander M. Turek --- .../DBAL/Schema/PostgreSqlSchemaManager.php | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index b5878bf2ae9..3678b42abe3 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -21,7 +21,6 @@ use function preg_replace; use function sprintf; use function str_replace; -use function strlen; use function strpos; use function strtolower; use function trim; @@ -336,16 +335,22 @@ protected function _getPortableTableColumnDefinition($tableColumn) $matches = []; $autoincrement = false; - if (preg_match("/^nextval\('(.*)'(::.*)?\)$/", $tableColumn['default'], $matches)) { + + if ( + $tableColumn['default'] !== null + && preg_match("/^nextval\('(.*)'(::.*)?\)$/", $tableColumn['default'], $matches) === 1 + ) { $tableColumn['sequence'] = $matches[1]; $tableColumn['default'] = null; $autoincrement = true; } - if (preg_match("/^['(](.*)[')]::/", $tableColumn['default'], $matches)) { - $tableColumn['default'] = $matches[1]; - } elseif (preg_match('/^NULL::/', $tableColumn['default'])) { - $tableColumn['default'] = null; + if ($tableColumn['default'] !== null) { + if (preg_match("/^['(](.*)[')]::/", $tableColumn['default'], $matches) === 1) { + $tableColumn['default'] = $matches[1]; + } elseif (preg_match('/^NULL::/', $tableColumn['default']) === 1) { + $tableColumn['default'] = null; + } } $length = $tableColumn['length'] ?? null; @@ -369,7 +374,8 @@ protected function _getPortableTableColumnDefinition($tableColumn) $dbType = strtolower($tableColumn['type']); if ( - strlen($tableColumn['domain_type']) + $tableColumn['domain_type'] !== null + && $tableColumn['domain_type'] !== '' && ! $this->_platform->hasDoctrineTypeMappingFor($tableColumn['type']) ) { $dbType = strtolower($tableColumn['domain_type']); @@ -497,7 +503,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) */ private function fixVersion94NegativeNumericDefaultValue($defaultValue) { - if (strpos($defaultValue, '(') === 0) { + if ($defaultValue !== null && strpos($defaultValue, '(') === 0) { return trim($defaultValue, '()'); } From 179becc0da2b2948c7ed2af99e0462ebea3f5c78 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 Oct 2021 23:44:30 +0200 Subject: [PATCH 5/5] Let the CI fail on deprecations --- ci/github/phpunit/ibm_db2.xml | 3 +++ ci/github/phpunit/mysqli-tls.xml | 3 +++ ci/github/phpunit/mysqli.xml | 3 +++ ci/github/phpunit/oci8.xml | 3 +++ ci/github/phpunit/pdo_mysql.xml | 3 +++ ci/github/phpunit/pdo_oci.xml | 3 +++ ci/github/phpunit/pdo_pgsql.xml | 3 +++ ci/github/phpunit/sqlite.xml | 5 +++++ 8 files changed, 26 insertions(+) diff --git a/ci/github/phpunit/ibm_db2.xml b/ci/github/phpunit/ibm_db2.xml index 178a69f7dab..79697dd5b77 100644 --- a/ci/github/phpunit/ibm_db2.xml +++ b/ci/github/phpunit/ibm_db2.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/mysqli-tls.xml b/ci/github/phpunit/mysqli-tls.xml index b07f6001827..a962d1d1b98 100644 --- a/ci/github/phpunit/mysqli-tls.xml +++ b/ci/github/phpunit/mysqli-tls.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml index 8dc53ce67bb..0fb53e1d1f0 100644 --- a/ci/github/phpunit/mysqli.xml +++ b/ci/github/phpunit/mysqli.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/oci8.xml b/ci/github/phpunit/oci8.xml index 12612514505..2c895d3915f 100644 --- a/ci/github/phpunit/oci8.xml +++ b/ci/github/phpunit/oci8.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml index ebbf5698b4c..0f1bdb5454e 100644 --- a/ci/github/phpunit/pdo_mysql.xml +++ b/ci/github/phpunit/pdo_mysql.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/pdo_oci.xml b/ci/github/phpunit/pdo_oci.xml index 5839be61980..1573957f664 100644 --- a/ci/github/phpunit/pdo_oci.xml +++ b/ci/github/phpunit/pdo_oci.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/pdo_pgsql.xml b/ci/github/phpunit/pdo_pgsql.xml index 08d4be0fcb8..6d9b10966f8 100644 --- a/ci/github/phpunit/pdo_pgsql.xml +++ b/ci/github/phpunit/pdo_pgsql.xml @@ -6,8 +6,11 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + diff --git a/ci/github/phpunit/sqlite.xml b/ci/github/phpunit/sqlite.xml index d8fe1d21670..85013213631 100644 --- a/ci/github/phpunit/sqlite.xml +++ b/ci/github/phpunit/sqlite.xml @@ -6,7 +6,12 @@ beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" failOnWarning="true" + convertDeprecationsToExceptions="true" > + + + + ../../../tests