Commit 867824b7 authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #580 from JeroenDeDauw/Table

Documentation and style improvements to Table
parents aaead5a7 77cdde2a
...@@ -38,12 +38,12 @@ class Table extends AbstractAsset ...@@ -38,12 +38,12 @@ class Table extends AbstractAsset
protected $_name = null; protected $_name = null;
/** /**
* @var \Doctrine\DBAL\Schema\Column[] * @var Column[]
*/ */
protected $_columns = array(); protected $_columns = array();
/** /**
* @var \Doctrine\DBAL\Schema\Index[] * @var Index[]
*/ */
protected $_indexes = array(); protected $_indexes = array();
...@@ -53,7 +53,7 @@ class Table extends AbstractAsset ...@@ -53,7 +53,7 @@ class Table extends AbstractAsset
protected $_primaryKeyName = false; protected $_primaryKeyName = false;
/** /**
* @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] * @var ForeignKeyConstraint[]
*/ */
protected $_fkConstraints = array(); protected $_fkConstraints = array();
...@@ -63,19 +63,19 @@ class Table extends AbstractAsset ...@@ -63,19 +63,19 @@ class Table extends AbstractAsset
protected $_options = array(); protected $_options = array();
/** /**
* @var \Doctrine\DBAL\Schema\SchemaConfig * @var SchemaConfig
*/ */
protected $_schemaConfig = null; protected $_schemaConfig = null;
/** /**
* @param string $tableName * @param string $tableName
* @param array $columns * @param Column[] $columns
* @param array $indexes * @param Index[] $indexes
* @param array $fkConstraints * @param ForeignKeyConstraint[] $fkConstraints
* @param integer $idGeneratorType * @param integer $idGeneratorType
* @param array $options * @param array $options
* *
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
*/ */
public function __construct($tableName, array $columns=array(), array $indexes=array(), array $fkConstraints=array(), $idGeneratorType = 0, array $options=array()) public function __construct($tableName, array $columns=array(), array $indexes=array(), array $fkConstraints=array(), $idGeneratorType = 0, array $options=array())
{ {
...@@ -101,7 +101,7 @@ class Table extends AbstractAsset ...@@ -101,7 +101,7 @@ class Table extends AbstractAsset
} }
/** /**
* @param \Doctrine\DBAL\Schema\SchemaConfig $schemaConfig * @param SchemaConfig $schemaConfig
* *
* @return void * @return void
*/ */
...@@ -128,18 +128,18 @@ class Table extends AbstractAsset ...@@ -128,18 +128,18 @@ class Table extends AbstractAsset
* @param array $columns * @param array $columns
* @param string|boolean $indexName * @param string|boolean $indexName
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function setPrimaryKey(array $columns, $indexName = false) public function setPrimaryKey(array $columns, $indexName = false)
{ {
$primaryKey = $this->_createIndex($columns, $indexName ?: "primary", true, true); $this->_addIndex($this->_createIndex($columns, $indexName ?: "primary", true, true));
foreach ($columns as $columnName) { foreach ($columns as $columnName) {
$column = $this->getColumn($columnName); $column = $this->getColumn($columnName);
$column->setNotnull(true); $column->setNotnull(true);
} }
return $primaryKey; return $this;
} }
/** /**
...@@ -147,7 +147,7 @@ class Table extends AbstractAsset ...@@ -147,7 +147,7 @@ class Table extends AbstractAsset
* @param string|null $indexName * @param string|null $indexName
* @param array $flags * @param array $flags
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function addIndex(array $columnNames, $indexName = null, array $flags = array()) public function addIndex(array $columnNames, $indexName = null, array $flags = array())
{ {
...@@ -157,7 +157,7 @@ class Table extends AbstractAsset ...@@ -157,7 +157,7 @@ class Table extends AbstractAsset
); );
} }
return $this->_createIndex($columnNames, $indexName, false, false, $flags); return $this->_addIndex($this->_createIndex($columnNames, $indexName, false, false, $flags));
} }
/** /**
...@@ -178,7 +178,7 @@ class Table extends AbstractAsset ...@@ -178,7 +178,7 @@ class Table extends AbstractAsset
* *
* @return void * @return void
* *
* @throws \Doctrine\DBAL\Schema\SchemaException If the index does not exist. * @throws SchemaException If the index does not exist.
*/ */
public function dropIndex($indexName) public function dropIndex($indexName)
{ {
...@@ -193,7 +193,7 @@ class Table extends AbstractAsset ...@@ -193,7 +193,7 @@ class Table extends AbstractAsset
* @param array $columnNames * @param array $columnNames
* @param string|null $indexName * @param string|null $indexName
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function addUniqueIndex(array $columnNames, $indexName = null) public function addUniqueIndex(array $columnNames, $indexName = null)
{ {
...@@ -203,7 +203,7 @@ class Table extends AbstractAsset ...@@ -203,7 +203,7 @@ class Table extends AbstractAsset
); );
} }
return $this->_createIndex($columnNames, $indexName, true, false); return $this->_addIndex($this->_createIndex($columnNames, $indexName, true, false));
} }
/** /**
...@@ -213,7 +213,7 @@ class Table extends AbstractAsset ...@@ -213,7 +213,7 @@ class Table extends AbstractAsset
* @param string|null $newIndexName The name of the index to rename to. * @param string|null $newIndexName The name of the index to rename to.
* If null is given, the index name will be auto-generated. * If null is given, the index name will be auto-generated.
* *
* @return \Doctrine\DBAL\Schema\Table This table instance. * @return self This table instance.
* *
* @throws SchemaException if no index exists for the given current name * @throws SchemaException if no index exists for the given current name
* or if an index with the given new name already exists on this table. * or if an index with the given new name already exists on this table.
...@@ -278,9 +278,9 @@ class Table extends AbstractAsset ...@@ -278,9 +278,9 @@ class Table extends AbstractAsset
* @param boolean $isPrimary * @param boolean $isPrimary
* @param array $flags * @param array $flags
* *
* @return \Doctrine\DBAL\Schema\Table * @return Index
* *
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws SchemaException
*/ */
private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = array()) private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = array())
{ {
...@@ -298,9 +298,7 @@ class Table extends AbstractAsset ...@@ -298,9 +298,7 @@ class Table extends AbstractAsset
} }
} }
$this->_addIndex(new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags)); return new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags);
return $this;
} }
/** /**
...@@ -308,7 +306,7 @@ class Table extends AbstractAsset ...@@ -308,7 +306,7 @@ class Table extends AbstractAsset
* @param string $typeName * @param string $typeName
* @param array $options * @param array $options
* *
* @return \Doctrine\DBAL\Schema\Column * @return Column
*/ */
public function addColumn($columnName, $typeName, array $options=array()) public function addColumn($columnName, $typeName, array $options=array())
{ {
...@@ -325,9 +323,9 @@ class Table extends AbstractAsset ...@@ -325,9 +323,9 @@ class Table extends AbstractAsset
* @param string $oldColumnName * @param string $oldColumnName
* @param string $newColumnName * @param string $newColumnName
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
* *
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
*/ */
public function renameColumn($oldColumnName, $newColumnName) public function renameColumn($oldColumnName, $newColumnName)
{ {
...@@ -342,7 +340,7 @@ class Table extends AbstractAsset ...@@ -342,7 +340,7 @@ class Table extends AbstractAsset
* @param string $columnName * @param string $columnName
* @param array $options * @param array $options
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function changeColumn($columnName, array $options) public function changeColumn($columnName, array $options)
{ {
...@@ -357,7 +355,7 @@ class Table extends AbstractAsset ...@@ -357,7 +355,7 @@ class Table extends AbstractAsset
* *
* @param string $columnName * @param string $columnName
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function dropColumn($columnName) public function dropColumn($columnName)
{ {
...@@ -372,13 +370,13 @@ class Table extends AbstractAsset ...@@ -372,13 +370,13 @@ class Table extends AbstractAsset
* *
* Name is inferred from the local columns. * Name is inferred from the local columns.
* *
* @param \Doctrine\DBAL\Schema\Table|string $foreignTable Table schema instance or table name * @param Table|string $foreignTable Table schema instance or table name
* @param array $localColumnNames * @param array $localColumnNames
* @param array $foreignColumnNames * @param array $foreignColumnNames
* @param array $options * @param array $options
* @param string|null $constraintName * @param string|null $constraintName
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array(), $constraintName = null) public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array(), $constraintName = null)
{ {
...@@ -394,12 +392,12 @@ class Table extends AbstractAsset ...@@ -394,12 +392,12 @@ class Table extends AbstractAsset
* *
* @deprecated Use {@link addForeignKeyConstraint} * @deprecated Use {@link addForeignKeyConstraint}
* *
* @param \Doctrine\DBAL\Schema\Table|string $foreignTable Table schema instance or table name * @param Table|string $foreignTable Table schema instance or table name
* @param array $localColumnNames * @param array $localColumnNames
* @param array $foreignColumnNames * @param array $foreignColumnNames
* @param array $options * @param array $options
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array()) public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array())
{ {
...@@ -411,15 +409,15 @@ class Table extends AbstractAsset ...@@ -411,15 +409,15 @@ class Table extends AbstractAsset
* *
* @deprecated Use {@link addForeignKeyConstraint} * @deprecated Use {@link addForeignKeyConstraint}
* *
* @param string $name * @param string $name
* @param \Doctrine\DBAL\Schema\Table|string $foreignTable Table schema instance or table name * @param Table|string $foreignTable Table schema instance or table name
* @param array $localColumnNames * @param array $localColumnNames
* @param array $foreignColumnNames * @param array $foreignColumnNames
* @param array $options * @param array $options
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
* *
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws SchemaException
*/ */
public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array()) public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array())
{ {
...@@ -449,7 +447,7 @@ class Table extends AbstractAsset ...@@ -449,7 +447,7 @@ class Table extends AbstractAsset
* @param string $name * @param string $name
* @param string $value * @param string $value
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
*/ */
public function addOption($name, $value) public function addOption($name, $value)
{ {
...@@ -459,11 +457,11 @@ class Table extends AbstractAsset ...@@ -459,11 +457,11 @@ class Table extends AbstractAsset
} }
/** /**
* @param \Doctrine\DBAL\Schema\Column $column * @param Column $column
* *
* @return void * @return void
* *
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws SchemaException
*/ */
protected function _addColumn(Column $column) protected function _addColumn(Column $column)
{ {
...@@ -480,11 +478,11 @@ class Table extends AbstractAsset ...@@ -480,11 +478,11 @@ class Table extends AbstractAsset
/** /**
* Adds an index to the table. * Adds an index to the table.
* *
* @param \Doctrine\DBAL\Schema\Index $indexCandidate * @param Index $indexCandidate
* *
* @return \Doctrine\DBAL\Schema\Table * @return self
* *
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws SchemaException
*/ */
protected function _addIndex(Index $indexCandidate) protected function _addIndex(Index $indexCandidate)
{ {
...@@ -519,7 +517,7 @@ class Table extends AbstractAsset ...@@ -519,7 +517,7 @@ class Table extends AbstractAsset
} }
/** /**
* @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $constraint * @param ForeignKeyConstraint $constraint
* *
* @return void * @return void
*/ */
...@@ -562,9 +560,9 @@ class Table extends AbstractAsset ...@@ -562,9 +560,9 @@ class Table extends AbstractAsset
* *
* @param string $constraintName The constraint name. * @param string $constraintName The constraint name.
* *
* @return \Doctrine\DBAL\Schema\ForeignKeyConstraint * @return ForeignKeyConstraint
* *
* @throws \Doctrine\DBAL\Schema\SchemaException If the foreign key does not exist. * @throws SchemaException If the foreign key does not exist.
*/ */
public function getForeignKey($constraintName) public function getForeignKey($constraintName)
{ {
...@@ -583,7 +581,7 @@ class Table extends AbstractAsset ...@@ -583,7 +581,7 @@ class Table extends AbstractAsset
* *
* @return void * @return void
* *
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws SchemaException
*/ */
public function removeForeignKey($constraintName) public function removeForeignKey($constraintName)
{ {
...@@ -596,7 +594,7 @@ class Table extends AbstractAsset ...@@ -596,7 +594,7 @@ class Table extends AbstractAsset
} }
/** /**
* @return \Doctrine\DBAL\Schema\Column[] * @return Column[]
*/ */
public function getColumns() public function getColumns()
{ {
...@@ -640,9 +638,9 @@ class Table extends AbstractAsset ...@@ -640,9 +638,9 @@ class Table extends AbstractAsset
* *
* @param string $columnName The column name. * @param string $columnName The column name.
* *
* @return \Doctrine\DBAL\Schema\Column * @return Column
* *
* @throws \Doctrine\DBAL\Schema\SchemaException If the column does not exist. * @throws SchemaException If the column does not exist.
*/ */
public function getColumn($columnName) public function getColumn($columnName)
{ {
...@@ -657,7 +655,7 @@ class Table extends AbstractAsset ...@@ -657,7 +655,7 @@ class Table extends AbstractAsset
/** /**
* Returns the primary key. * Returns the primary key.
* *
* @return \Doctrine\DBAL\Schema\Index|null The primary key, or null if this Table has no primary key. * @return Index|null The primary key, or null if this Table has no primary key.
*/ */
public function getPrimaryKey() public function getPrimaryKey()
{ {
...@@ -673,7 +671,7 @@ class Table extends AbstractAsset ...@@ -673,7 +671,7 @@ class Table extends AbstractAsset
* *
* @return array * @return array
* *
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
*/ */
public function getPrimaryKeyColumns() public function getPrimaryKeyColumns()
{ {
...@@ -713,9 +711,9 @@ class Table extends AbstractAsset ...@@ -713,9 +711,9 @@ class Table extends AbstractAsset
* *
* @param string $indexName The index name. * @param string $indexName The index name.
* *
* @return \Doctrine\DBAL\Schema\Index * @return Index
* *
* @throws \Doctrine\DBAL\Schema\SchemaException If the index does not exist. * @throws SchemaException If the index does not exist.
*/ */
public function getIndex($indexName) public function getIndex($indexName)
{ {
...@@ -728,7 +726,7 @@ class Table extends AbstractAsset ...@@ -728,7 +726,7 @@ class Table extends AbstractAsset
} }
/** /**
* @return \Doctrine\DBAL\Schema\Index[] * @return Index[]
*/ */
public function getIndexes() public function getIndexes()
{ {
...@@ -738,7 +736,7 @@ class Table extends AbstractAsset ...@@ -738,7 +736,7 @@ class Table extends AbstractAsset
/** /**
* Returns the foreign key constraints. * Returns the foreign key constraints.
* *
* @return \Doctrine\DBAL\Schema\ForeignKeyConstraint[] * @return ForeignKeyConstraint[]
*/ */
public function getForeignKeys() public function getForeignKeys()
{ {
...@@ -774,7 +772,7 @@ class Table extends AbstractAsset ...@@ -774,7 +772,7 @@ class Table extends AbstractAsset
} }
/** /**
* @param \Doctrine\DBAL\Schema\Visitor\Visitor $visitor * @param Visitor $visitor
* *
* @return void * @return void
*/ */
......
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