diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 664451feb49..ebda6402cbb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -140,14 +140,5 @@ parameters: # Ignore the possible false return value of db2_num_rows(). - '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Connection\:\:exec\(\) should return int but returns int<0, max>\|false\.$~' - '~^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Result\:\:rowCount\(\) should return int but returns int<0, max>\|false\.$~' - - # https://github.com/doctrine/dbal/pull/6202 - # TODO: remove in 4.0.0 - - '~^Method Doctrine\\DBAL\\Platforms\\AbstractMySQLPlatform\:\:getColumnTypeSQLSnippets\(\) invoked with 2 parameters, 0-1 required\.\z~' - - - message: '~^PHPDoc tag \@param references unknown parameter\: \$databaseName$~' - paths: - - src/Platforms/AbstractMySQLPlatform.php - - src/Platforms/MariaDb1043Platform.php includes: - vendor/phpstan/phpstan-strict-rules/rules.neon diff --git a/psalm.xml.dist b/psalm.xml.dist index dff9b2c03bb..33db79378c0 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -499,6 +499,11 @@ --> + + @@ -791,8 +796,6 @@ - - diff --git a/src/Platforms/AbstractMySQLPlatform.php b/src/Platforms/AbstractMySQLPlatform.php index 6c1dbbd82a8..102c567c272 100644 --- a/src/Platforms/AbstractMySQLPlatform.php +++ b/src/Platforms/AbstractMySQLPlatform.php @@ -398,17 +398,34 @@ public function getListTableColumnsSQL($table, $database = null) } /** + * @deprecated Use {@see getColumnTypeSQLSnippet()} instead. + * * The SQL snippets required to elucidate a column type * * Returns an array of the form [column type SELECT snippet, additional JOIN statement snippet] * - * @param string|null $databaseName - * * @return array{string, string} */ - public function getColumnTypeSQLSnippets(string $tableAlias = 'c' /* , ?string $databaseName = null*/): array + public function getColumnTypeSQLSnippets(string $tableAlias = 'c'): array + { + Deprecation::triggerIfCalledFromOutside( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/6202', + 'AbstractMySQLPlatform::getColumnTypeSQLSnippets() is deprecated. ' + . 'Use AbstractMySQLPlatform::getColumnTypeSQLSnippet() instead.', + ); + + return [$this->getColumnTypeSQLSnippet(...func_get_args()), '']; + } + + /** + * The SQL snippet required to elucidate a column type + * + * Returns a column type SELECT snippet string + */ + public function getColumnTypeSQLSnippet(string $tableAlias = 'c', ?string $databaseName = null): string { - return [$tableAlias . '.COLUMN_TYPE', '']; + return $tableAlias . '.COLUMN_TYPE'; } /** @deprecated The SQL used for schema introspection is an implementation detail and should not be relied upon. */ diff --git a/src/Platforms/MariaDb1043Platform.php b/src/Platforms/MariaDb1043Platform.php index ae5ce164220..a3c96d95669 100644 --- a/src/Platforms/MariaDb1043Platform.php +++ b/src/Platforms/MariaDb1043Platform.php @@ -42,6 +42,7 @@ public function getJsonTypeDeclarationSQL(array $column): string */ public function getListTableColumnsSQL($table, $database = null): string { + // @todo 4.0 - call getColumnTypeSQLSnippet() instead [$columnTypeSQL, $joinCheckConstraintSQL] = $this->getColumnTypeSQLSnippets('c', $database); return sprintf( @@ -75,23 +76,17 @@ public function getListTableColumnsSQL($table, $database = null): string * as JSON where it was originally specified as such instead of LONGTEXT. * * The CHECK constraints are stored in information_schema.CHECK_CONSTRAINTS so query that table. - * - * @param string|null $databaseName - * - * @return array{string, string} */ - public function getColumnTypeSQLSnippets(string $tableAlias = 'c' /* , ?string $databaseName = null*/): array + public function getColumnTypeSQLSnippet(string $tableAlias = 'c', ?string $databaseName = null): string { - $databaseName = func_num_args() > 1 ? func_get_arg(1) : null; - if ($this->getJsonTypeDeclarationSQL([]) !== 'JSON') { - return parent::getColumnTypeSQLSnippets($tableAlias, $databaseName); + return parent::getColumnTypeSQLSnippet($tableAlias, $databaseName); } $databaseName = $this->getDatabaseNameSQL($databaseName); // The check for `CONSTRAINT_SCHEMA = $databaseName` is mandatory here to prevent performance issues - $columnTypeSQL = <<_platform->getColumnTypeSQLSnippets('c', $databaseName); $sql = 'SELECT';