Make the $tableName argument of _getPortableTableIndexesList() required

1. The argument is always available since the method is only called from listTableIndexes() which requires a table name.
2. The argument itself seems a workaround and only needed to bypass the fact that the SQLiteSchemaManager violates the method contract: instead of reformatting the provided data it fetches more data from the DB schema which requires a table name. This argument should be dropped completely later.
parent 6bed1f4e
......@@ -837,11 +837,10 @@ abstract class AbstractSchemaManager
* Aggregates and groups the index results according to the required data result.
*
* @param mixed[][] $tableIndexRows
* @param string|null $tableName
*
* @return Index[]
*/
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
$result = [];
foreach ($tableIndexRows as $tableIndex) {
......
......@@ -127,7 +127,7 @@ class DB2SchemaManager extends AbstractSchemaManager
/**
* {@inheritdoc}
*/
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
foreach ($tableIndexRows as &$tableIndexRow) {
$tableIndexRow = array_change_key_case($tableIndexRow, CASE_LOWER);
......
......@@ -73,9 +73,9 @@ class MySqlSchemaManager extends AbstractSchemaManager
/**
* {@inheritdoc}
*/
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
foreach ($tableIndexes as $k => $v) {
foreach ($tableIndexRows as $k => $v) {
$v = array_change_key_case($v, CASE_LOWER);
if ($v['key_name'] === 'PRIMARY') {
$v['primary'] = true;
......@@ -89,10 +89,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
$v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null;
$tableIndexes[$k] = $v;
$tableIndexRows[$k] = $v;
}
return parent::_getPortableTableIndexesList($tableIndexes, $tableName);
return parent::_getPortableTableIndexesList($tableIndexRows, $tableName);
}
/**
......
......@@ -90,10 +90,10 @@ class OracleSchemaManager extends AbstractSchemaManager
*
* @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html
*/
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
$indexBuffer = [];
foreach ($tableIndexes as $tableIndex) {
foreach ($tableIndexRows as $tableIndex) {
$tableIndex = array_change_key_case($tableIndex, CASE_LOWER);
$keyName = strtolower($tableIndex['name']);
......
......@@ -209,10 +209,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
*
* @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html
*/
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
$buffer = [];
foreach ($tableIndexes as $row) {
foreach ($tableIndexRows as $row) {
$colNumbers = array_map('intval', explode(' ', $row['indkey']));
$columnNameSql = sprintf(
'SELECT attnum, attname FROM pg_attribute WHERE attrelid=%d AND attnum IN (%s) ORDER BY attnum ASC',
......
......@@ -194,7 +194,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
/**
* {@inheritdoc}
*/
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
foreach ($tableIndexRows as &$tableIndex) {
$tableIndex['primary'] = (bool) $tableIndex['primary'];
......
......@@ -176,7 +176,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
/**
* {@inheritdoc}
*/
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
foreach ($tableIndexRows as &$tableIndex) {
$tableIndex['non_unique'] = (bool) $tableIndex['non_unique'];
......
......@@ -163,7 +163,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
*
* @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html
*/
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array
{
$indexBuffer = [];
......@@ -195,7 +195,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
}
// fetch regular indexes
foreach ($tableIndexes as $tableIndex) {
foreach ($tableIndexRows as $tableIndex) {
// Ignore indexes with reserved names, e.g. autoindexes
if (strpos($tableIndex['name'], 'sqlite_') === 0) {
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment