Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions lib/Doctrine/DBAL/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use function array_filter;
use function array_merge;
use function in_array;
use function is_numeric;
use function is_string;
use function preg_match;
use function strlen;
use function strtolower;
Expand Down Expand Up @@ -100,16 +98,16 @@ protected function _getMaxIdentifierLength()
/**
* Sets the Primary Key.
*
* @param mixed[][] $columns
* @param string[] $columnNames
* @param string|bool $indexName
*
* @return self
*/
public function setPrimaryKey(array $columns, $indexName = false)
public function setPrimaryKey(array $columnNames, $indexName = false)
{
$this->_addIndex($this->_createIndex($columns, $indexName ?: 'primary', true, true));
$this->_addIndex($this->_createIndex($columnNames, $indexName ?: 'primary', true, true));

foreach ($columns as $columnName) {
foreach ($columnNames as $columnName) {
$column = $this->getColumn($columnName);
$column->setNotnull(true);
}
Expand All @@ -118,7 +116,7 @@ public function setPrimaryKey(array $columns, $indexName = false)
}

/**
* @param mixed[][] $columnNames
* @param string[] $columnNames
* @param string|null $indexName
* @param string[] $flags
* @param mixed[] $options
Expand Down Expand Up @@ -168,7 +166,7 @@ public function dropIndex($indexName)
}

/**
* @param mixed[][] $columnNames
* @param string[] $columnNames
* @param string|null $indexName
* @param mixed[] $options
*
Expand Down Expand Up @@ -236,15 +234,15 @@ public function renameIndex($oldIndexName, $newIndexName = null)
/**
* Checks if an index begins in the order of the given columns.
*
* @param mixed[][] $columnsNames
* @param string[] $columnNames
*
* @return bool
*/
public function columnsAreIndexed(array $columnsNames)
public function columnsAreIndexed(array $columnNames)
{
foreach ($this->getIndexes() as $index) {
/** @var $index Index */
if ($index->spansColumns($columnsNames)) {
if ($index->spansColumns($columnNames)) {
return true;
}
}
Expand All @@ -253,12 +251,12 @@ public function columnsAreIndexed(array $columnsNames)
}

/**
* @param mixed[][] $columnNames
* @param string $indexName
* @param bool $isUnique
* @param bool $isPrimary
* @param string[] $flags
* @param mixed[] $options
* @param string[] $columnNames
* @param string $indexName
* @param bool $isUnique
* @param bool $isPrimary
* @param string[] $flags
* @param mixed[] $options
*
* @return Index
*
Expand All @@ -270,11 +268,7 @@ private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrim
throw SchemaException::indexNameInvalid($indexName);
}

foreach ($columnNames as $columnName => $indexColOptions) {
if (is_numeric($columnName) && is_string($indexColOptions)) {
$columnName = $indexColOptions;
}

foreach ($columnNames as $columnName) {
if (! $this->hasColumn($columnName)) {
throw SchemaException::columnDoesNotExist($columnName, $this->_name);
}
Expand Down