Unverified Commit b84603b9 authored by Lukas Vitek's avatar Lukas Vitek Committed by Sergei Morozov

Fixed annotation and name of parameter $columnsNames in Table

parent 5d4f9335
...@@ -9,8 +9,6 @@ use const ARRAY_FILTER_USE_KEY; ...@@ -9,8 +9,6 @@ use const ARRAY_FILTER_USE_KEY;
use function array_filter; use function array_filter;
use function array_merge; use function array_merge;
use function in_array; use function in_array;
use function is_numeric;
use function is_string;
use function preg_match; use function preg_match;
use function strlen; use function strlen;
use function strtolower; use function strtolower;
...@@ -100,16 +98,16 @@ class Table extends AbstractAsset ...@@ -100,16 +98,16 @@ class Table extends AbstractAsset
/** /**
* Sets the Primary Key. * Sets the Primary Key.
* *
* @param mixed[][] $columns * @param string[] $columnNames
* @param string|bool $indexName * @param string|bool $indexName
* *
* @return self * @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 = $this->getColumn($columnName);
$column->setNotnull(true); $column->setNotnull(true);
} }
...@@ -118,7 +116,7 @@ class Table extends AbstractAsset ...@@ -118,7 +116,7 @@ class Table extends AbstractAsset
} }
/** /**
* @param mixed[][] $columnNames * @param string[] $columnNames
* @param string|null $indexName * @param string|null $indexName
* @param string[] $flags * @param string[] $flags
* @param mixed[] $options * @param mixed[] $options
...@@ -168,7 +166,7 @@ class Table extends AbstractAsset ...@@ -168,7 +166,7 @@ class Table extends AbstractAsset
} }
/** /**
* @param mixed[][] $columnNames * @param string[] $columnNames
* @param string|null $indexName * @param string|null $indexName
* @param mixed[] $options * @param mixed[] $options
* *
...@@ -236,15 +234,15 @@ class Table extends AbstractAsset ...@@ -236,15 +234,15 @@ class Table extends AbstractAsset
/** /**
* Checks if an index begins in the order of the given columns. * Checks if an index begins in the order of the given columns.
* *
* @param mixed[][] $columnsNames * @param string[] $columnNames
* *
* @return bool * @return bool
*/ */
public function columnsAreIndexed(array $columnsNames) public function columnsAreIndexed(array $columnNames)
{ {
foreach ($this->getIndexes() as $index) { foreach ($this->getIndexes() as $index) {
/** @var $index Index */ /** @var $index Index */
if ($index->spansColumns($columnsNames)) { if ($index->spansColumns($columnNames)) {
return true; return true;
} }
} }
...@@ -253,12 +251,12 @@ class Table extends AbstractAsset ...@@ -253,12 +251,12 @@ class Table extends AbstractAsset
} }
/** /**
* @param mixed[][] $columnNames * @param string[] $columnNames
* @param string $indexName * @param string $indexName
* @param bool $isUnique * @param bool $isUnique
* @param bool $isPrimary * @param bool $isPrimary
* @param string[] $flags * @param string[] $flags
* @param mixed[] $options * @param mixed[] $options
* *
* @return Index * @return Index
* *
...@@ -270,11 +268,7 @@ class Table extends AbstractAsset ...@@ -270,11 +268,7 @@ class Table extends AbstractAsset
throw SchemaException::indexNameInvalid($indexName); throw SchemaException::indexNameInvalid($indexName);
} }
foreach ($columnNames as $columnName => $indexColOptions) { foreach ($columnNames as $columnName) {
if (is_numeric($columnName) && is_string($indexColOptions)) {
$columnName = $indexColOptions;
}
if (! $this->hasColumn($columnName)) { if (! $this->hasColumn($columnName)) {
throw SchemaException::columnDoesNotExist($columnName, $this->_name); throw SchemaException::columnDoesNotExist($columnName, $this->_name);
} }
......
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