updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -4,20 +4,24 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs;
use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;
use Throwable;
use function array_filter;
use function array_intersect;
use function array_map;
use function array_values;
use function assert;
use function call_user_func_array;
use function count;
use function func_get_args;
use function is_array;
use function is_callable;
use function is_string;
use function preg_match;
use function str_replace;
use function strtolower;
@@ -80,8 +84,11 @@ abstract class AbstractSchemaManager
unset($args[0]);
$args = array_values($args);
$callback = [$this, $method];
assert(is_callable($callback));
try {
return call_user_func_array([$this, $method], $args);
return call_user_func_array($callback, $args);
} catch (Throwable $e) {
return false;
}
@@ -96,7 +103,7 @@ abstract class AbstractSchemaManager
{
$sql = $this->_platform->getListDatabasesSQL();
$databases = $this->_conn->fetchAll($sql);
$databases = $this->_conn->fetchAllAssociative($sql);
return $this->_getPortableDatabasesList($databases);
}
@@ -110,7 +117,7 @@ abstract class AbstractSchemaManager
{
$sql = $this->_platform->getListNamespacesSQL();
$namespaces = $this->_conn->fetchAll($sql);
$namespaces = $this->_conn->fetchAllAssociative($sql);
return $this->getPortableNamespacesList($namespaces);
}
@@ -127,9 +134,10 @@ abstract class AbstractSchemaManager
if ($database === null) {
$database = $this->_conn->getDatabase();
}
$sql = $this->_platform->getListSequencesSQL($database);
$sequences = $this->_conn->fetchAll($sql);
$sequences = $this->_conn->fetchAllAssociative($sql);
return $this->filterAssetNames($this->_getPortableSequencesList($sequences));
}
@@ -138,10 +146,10 @@ abstract class AbstractSchemaManager
* Lists the columns for a given table.
*
* In contrast to other libraries and to the old version of Doctrine,
* this column definition does try to contain the 'primary' field for
* this column definition does try to contain the 'primary' column for
* the reason that it is not portable across different RDBMS. Use
* {@see listTableIndexes($tableName)} to retrieve the primary key
* of a table. We're a RDBMS specifies more details these are held
* of a table. Where a RDBMS specifies more details, these are held
* in the platformDetails array.
*
* @param string $table The name of the table.
@@ -157,7 +165,7 @@ abstract class AbstractSchemaManager
$sql = $this->_platform->getListTableColumnsSQL($table, $database);
$tableColumns = $this->_conn->fetchAll($sql);
$tableColumns = $this->_conn->fetchAllAssociative($sql);
return $this->_getPortableTableColumnList($table, $database, $tableColumns);
}
@@ -175,7 +183,7 @@ abstract class AbstractSchemaManager
{
$sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase());
$tableIndexes = $this->_conn->fetchAll($sql);
$tableIndexes = $this->_conn->fetchAllAssociative($sql);
return $this->_getPortableTableIndexesList($tableIndexes, $table);
}
@@ -183,15 +191,26 @@ abstract class AbstractSchemaManager
/**
* Returns true if all the given tables exist.
*
* @param string[] $tableNames
* The usage of a string $tableNames is deprecated. Pass a one-element array instead.
*
* @param string|string[] $names
*
* @return bool
*/
public function tablesExist($tableNames)
public function tablesExist($names)
{
$tableNames = array_map('strtolower', (array) $tableNames);
if (is_string($names)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3580',
'The usage of a string $tableNames in AbstractSchemaManager::tablesExist is deprecated. ' .
'Pass a one-element array instead.'
);
}
return count($tableNames) === count(array_intersect($tableNames, array_map('strtolower', $this->listTableNames())));
$names = array_map('strtolower', (array) $names);
return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames())));
}
/**
@@ -203,7 +222,7 @@ abstract class AbstractSchemaManager
{
$sql = $this->_platform->getListTablesSQL();
$tables = $this->_conn->fetchAll($sql);
$tables = $this->_conn->fetchAllAssociative($sql);
$tableNames = $this->_getPortableTablesList($tables);
return $this->filterAssetNames($tableNames);
@@ -255,20 +274,21 @@ abstract class AbstractSchemaManager
}
/**
* @param string $tableName
* @param string $name
*
* @return Table
*/
public function listTableDetails($tableName)
public function listTableDetails($name)
{
$columns = $this->listTableColumns($tableName);
$columns = $this->listTableColumns($name);
$foreignKeys = [];
if ($this->_platform->supportsForeignKeyConstraints()) {
$foreignKeys = $this->listTableForeignKeys($tableName);
$foreignKeys = $this->listTableForeignKeys($name);
}
$indexes = $this->listTableIndexes($tableName);
return new Table($tableName, $columns, $indexes, $foreignKeys, false, []);
$indexes = $this->listTableIndexes($name);
return new Table($name, $columns, $indexes, $foreignKeys);
}
/**
@@ -280,7 +300,7 @@ abstract class AbstractSchemaManager
{
$database = $this->_conn->getDatabase();
$sql = $this->_platform->getListViewsSQL($database);
$views = $this->_conn->fetchAll($sql);
$views = $this->_conn->fetchAllAssociative($sql);
return $this->_getPortableViewsList($views);
}
@@ -298,8 +318,9 @@ abstract class AbstractSchemaManager
if ($database === null) {
$database = $this->_conn->getDatabase();
}
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql);
$tableForeignKeys = $this->_conn->fetchAllAssociative($sql);
return $this->_getPortableTableForeignKeysList($tableForeignKeys);
}
@@ -323,13 +344,13 @@ abstract class AbstractSchemaManager
/**
* Drops the given table.
*
* @param string $tableName The name of the table to drop.
* @param string $name The name of the table to drop.
*
* @return void
*/
public function dropTable($tableName)
public function dropTable($name)
{
$this->_execSql($this->_platform->getDropTableSQL($tableName));
$this->_execSql($this->_platform->getDropTableSQL($name));
}
/**
@@ -419,7 +440,7 @@ abstract class AbstractSchemaManager
*/
public function createTable(Table $table)
{
$createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS;
$createFlags = AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS;
$this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
}
@@ -518,7 +539,8 @@ abstract class AbstractSchemaManager
/**
* Drops and creates a new foreign key.
*
* @param ForeignKeyConstraint $foreignKey An associative array that defines properties of the foreign key to be created.
* @param ForeignKeyConstraint $foreignKey An associative array that defines properties
* of the foreign key to be created.
* @param Table|string $table The name of the table on which the foreign key is to be created.
*
* @return void
@@ -586,12 +608,7 @@ abstract class AbstractSchemaManager
*/
public function alterTable(TableDiff $tableDiff)
{
$queries = $this->_platform->getAlterTableSQL($tableDiff);
if (! is_array($queries) || ! count($queries)) {
return;
}
foreach ($queries as $ddlQuery) {
foreach ($this->_platform->getAlterTableSQL($tableDiff) as $ddlQuery) {
$this->_execSql($ddlQuery);
}
}
@@ -678,6 +695,8 @@ abstract class AbstractSchemaManager
}
/**
* @deprecated
*
* @param mixed[][] $functions
*
* @return mixed[][]
@@ -699,6 +718,8 @@ abstract class AbstractSchemaManager
}
/**
* @deprecated
*
* @param mixed[] $function
*
* @return mixed
@@ -747,14 +768,9 @@ abstract class AbstractSchemaManager
protected function _getPortableSequencesList($sequences)
{
$list = [];
foreach ($sequences as $value) {
$value = $this->_getPortableSequenceDefinition($value);
if (! $value) {
continue;
}
$list[] = $value;
$list[] = $this->_getPortableSequenceDefinition($value);
}
return $list;
@@ -765,11 +781,11 @@ abstract class AbstractSchemaManager
*
* @return Sequence
*
* @throws DBALException
* @throws Exception
*/
protected function _getPortableSequenceDefinition($sequence)
{
throw DBALException::notSupported('Sequences');
throw Exception::notSupported('Sequences');
}
/**
@@ -827,19 +843,20 @@ abstract class AbstractSchemaManager
/**
* Aggregates and groups the index results according to the required data result.
*
* @param mixed[][] $tableIndexRows
* @param mixed[][] $tableIndexes
* @param string|null $tableName
*
* @return Index[]
*/
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
{
$result = [];
foreach ($tableIndexRows as $tableIndex) {
foreach ($tableIndexes as $tableIndex) {
$indexName = $keyName = $tableIndex['key_name'];
if ($tableIndex['primary']) {
$keyName = 'primary';
}
$keyName = strtolower($keyName);
if (! isset($result[$keyName])) {
@@ -854,7 +871,7 @@ abstract class AbstractSchemaManager
$result[$keyName] = [
'name' => $indexName,
'columns' => [],
'unique' => $tableIndex['non_unique'] ? false : true,
'unique' => ! $tableIndex['non_unique'],
'primary' => $tableIndex['primary'],
'flags' => $tableIndex['flags'] ?? [],
'options' => $options,
@@ -881,7 +898,14 @@ abstract class AbstractSchemaManager
}
if (! $defaultPrevented) {
$index = new Index($data['name'], $data['columns'], $data['unique'], $data['primary'], $data['flags'], $data['options']);
$index = new Index(
$data['name'],
$data['columns'],
$data['unique'],
$data['primary'],
$data['flags'],
$data['options']
);
}
if (! $index) {
@@ -947,9 +971,9 @@ abstract class AbstractSchemaManager
}
/**
* @param mixed[] $user
* @param string[] $user
*
* @return mixed[]
* @return string[]
*/
protected function _getPortableUserDefinition($user)
{
@@ -996,14 +1020,9 @@ abstract class AbstractSchemaManager
protected function _getPortableTableForeignKeysList($tableForeignKeys)
{
$list = [];
foreach ($tableForeignKeys as $value) {
$value = $this->_getPortableTableForeignKeyDefinition($value);
if (! $value) {
continue;
}
$list[] = $value;
$list[] = $this->_getPortableTableForeignKeyDefinition($value);
}
return $list;
@@ -1027,7 +1046,7 @@ abstract class AbstractSchemaManager
protected function _execSql($sql)
{
foreach ((array) $sql as $query) {
$this->_conn->executeUpdate($query);
$this->_conn->executeStatement($query);
}
}
@@ -1074,9 +1093,11 @@ abstract class AbstractSchemaManager
if (! isset($params['defaultTableOptions'])) {
$params['defaultTableOptions'] = [];
}
if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) {
$params['defaultTableOptions']['charset'] = $params['charset'];
}
$schemaConfig->setDefaultTableOptions($params['defaultTableOptions']);
return $schemaConfig;
@@ -1103,28 +1124,32 @@ abstract class AbstractSchemaManager
* Given a table comment this method tries to extract a typehint for Doctrine Type, or returns
* the type given as default.
*
* @param string $comment
* @param string $currentType
* @param string|null $comment
* @param string $currentType
*
* @return string
*/
public function extractDoctrineTypeFromComment($comment, $currentType)
{
if (preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match)) {
$currentType = $match[1];
if ($comment !== null && preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match)) {
return $match[1];
}
return $currentType;
}
/**
* @param string $comment
* @param string $type
* @param string|null $comment
* @param string|null $type
*
* @return string
* @return string|null
*/
public function removeDoctrineTypeFromComment($comment, $type)
{
if ($comment === null) {
return null;
}
return str_replace('(DC2Type:' . $type . ')', '', $comment);
}
}