From a8019c65867646d54ed5c926ad68b38f6187f0fa Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 24 Mar 2012 10:53:34 +0100 Subject: [PATCH] Fix CS: Apply unused local variable changes by @hhamon - Fixes GH-91 --- lib/Doctrine/DBAL/Connection.php | 2 +- lib/Doctrine/DBAL/Platforms/DB2Platform.php | 4 ++-- lib/Doctrine/DBAL/Platforms/MySqlPlatform.php | 2 +- lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 6 +----- .../DBAL/Platforms/SQLServerPlatform.php | 3 +-- .../DBAL/Schema/AbstractSchemaManager.php | 18 +++++++++--------- lib/Doctrine/DBAL/Schema/Comparator.php | 2 +- lib/Doctrine/DBAL/Schema/DB2SchemaManager.php | 1 - .../DBAL/Schema/MySqlSchemaManager.php | 10 ++-------- .../DBAL/Schema/OracleSchemaManager.php | 2 +- 10 files changed, 19 insertions(+), 31 deletions(-) diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index b778d47f9e4..7e8addca024 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -1164,7 +1164,7 @@ private function _bindTypedValues($stmt, array $params, array $types) // Positional parameters $typeOffset = array_key_exists(0, $types) ? -1 : 0; $bindIndex = 1; - foreach ($params as $position => $value) { + foreach ($params as $value) { $typeIndex = $bindIndex + $typeOffset; if (isset($types[$typeIndex])) { $type = $types[$typeIndex]; diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index a6717817db5..8d1bf7331eb 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -358,7 +358,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options $sqls = parent::_getCreateTableSQL($tableName, $columns, $options); - foreach ($indexes as $index => $definition) { + foreach ($indexes as $definition) { $sqls[] = $this->getCreateIndexSQL($definition, $tableName); } return $sqls; @@ -376,7 +376,7 @@ public function getAlterTableSQL(TableDiff $diff) $columnSql = array(); $queryParts = array(); - foreach ($diff->addedColumns as $fieldName => $column) { + foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { continue; } diff --git a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index 17ca69f5b3c..3c02f0f575c 100644 --- a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -460,7 +460,7 @@ public function getAlterTableSQL(TableDiff $diff) $queryParts[] = 'RENAME TO ' . $diff->newName; } - foreach ($diff->addedColumns as $fieldName => $column) { + foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { continue; } diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 1dc7c2e8ad5..461e751da8a 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -354,7 +354,7 @@ protected function _getCreateTableSQL($table, array $columns, array $options = a } if (isset($indexes) && ! empty($indexes)) { - foreach ($indexes as $indexName => $index) { + foreach ($indexes as $index) { $sql[] = $this->getCreateIndexSQL($index, $table); } } @@ -408,10 +408,6 @@ public function getCreateAutoincrementSql($name, $table, $start = 1) $sql = array(); $indexName = $table . '_AI_PK'; - $definition = array( - 'primary' => true, - 'columns' => array($name => true), - ); $idx = new \Doctrine\DBAL\Schema\Index($indexName, array($name), true, true); diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 7db8d422145..a48af3a8cc9 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -153,7 +153,6 @@ public function getDropForeignKeySQL($foreignKey, $table) public function getDropIndexSQL($index, $table=null) { if ($index instanceof \Doctrine\DBAL\Schema\Index) { - $index_ = $index; $index = $index->getQuotedName($this); } else if (!is_string($index)) { throw new \InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'); @@ -322,7 +321,7 @@ public function getAlterTableSQL(TableDiff $diff) $queryParts[] = 'RENAME TO ' . $diff->newName; } - foreach ($diff->addedColumns as $fieldName => $column) { + foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { continue; } diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 494440ed9cf..8d0b1b16326 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -576,7 +576,7 @@ public function renameTable($name, $newName) protected function _getPortableDatabasesList($databases) { $list = array(); - foreach ($databases as $key => $value) { + foreach ($databases as $value) { if ($value = $this->_getPortableDatabaseDefinition($value)) { $list[] = $value; } @@ -592,7 +592,7 @@ protected function _getPortableDatabaseDefinition($database) protected function _getPortableFunctionsList($functions) { $list = array(); - foreach ($functions as $key => $value) { + foreach ($functions as $value) { if ($value = $this->_getPortableFunctionDefinition($value)) { $list[] = $value; } @@ -608,7 +608,7 @@ protected function _getPortableFunctionDefinition($function) protected function _getPortableTriggersList($triggers) { $list = array(); - foreach ($triggers as $key => $value) { + foreach ($triggers as $value) { if ($value = $this->_getPortableTriggerDefinition($value)) { $list[] = $value; } @@ -624,7 +624,7 @@ protected function _getPortableTriggerDefinition($trigger) protected function _getPortableSequencesList($sequences) { $list = array(); - foreach ($sequences as $key => $value) { + foreach ($sequences as $value) { if ($value = $this->_getPortableSequenceDefinition($value)) { $list[] = $value; } @@ -656,7 +656,7 @@ protected function _getPortableTableColumnList($table, $database, $tableColumns) $eventManager = $this->_platform->getEventManager(); $list = array(); - foreach ($tableColumns as $key => $tableColumn) { + foreach ($tableColumns as $tableColumn) { $column = null; $defaultPrevented = false; @@ -748,7 +748,7 @@ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null protected function _getPortableTablesList($tables) { $list = array(); - foreach ($tables as $key => $value) { + foreach ($tables as $value) { if ($value = $this->_getPortableTableDefinition($value)) { $list[] = $value; } @@ -764,7 +764,7 @@ protected function _getPortableTableDefinition($table) protected function _getPortableUsersList($users) { $list = array(); - foreach ($users as $key => $value) { + foreach ($users as $value) { if ($value = $this->_getPortableUserDefinition($value)) { $list[] = $value; } @@ -780,7 +780,7 @@ protected function _getPortableUserDefinition($user) protected function _getPortableViewsList($views) { $list = array(); - foreach ($views as $key => $value) { + foreach ($views as $value) { if ($view = $this->_getPortableViewDefinition($value)) { $viewName = strtolower($view->getQuotedName($this->_platform)); $list[$viewName] = $view; @@ -797,7 +797,7 @@ protected function _getPortableViewDefinition($view) protected function _getPortableTableForeignKeysList($tableForeignKeys) { $list = array(); - foreach ($tableForeignKeys as $key => $value) { + foreach ($tableForeignKeys as $value) { if ($value = $this->_getPortableTableForeignKeyDefinition($value)) { $list[] = $value; } diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php index 554a043f560..981b0f570ff 100644 --- a/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/lib/Doctrine/DBAL/Schema/Comparator.php @@ -261,7 +261,7 @@ private function detectColumnRenamings(TableDiff $tableDifferences) } } - foreach ($renameCandidates as $candidate => $candidateColumns) { + foreach ($renameCandidates as $candidateColumns) { if (count($candidateColumns) == 1) { list($removedColumn, $addedColumn) = $candidateColumns[0]; $removedColumnName = strtolower($removedColumn->getName()); diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index ae845f84d72..61f9c4ff975 100644 --- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -124,7 +124,6 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { $eventManager = $this->_platform->getEventManager(); - $tableIndexRows = array(); $indexes = array(); foreach($tableIndexes as $indexKey => $data) { $data = array_change_key_case($data, \CASE_LOWER); diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 983142eaf83..4a1ecbdc006 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -146,17 +146,11 @@ protected function _getPortableTableColumnDefinition($tableColumn) } $length = ((int) $length == 0) ? null : (int) $length; - $def = array( - 'type' => $type, - 'length' => $length, - 'unsigned' => (bool) $unsigned, - 'fixed' => (bool) $fixed - ); $options = array( 'length' => $length, - 'unsigned' => (bool)$unsigned, - 'fixed' => (bool)$fixed, + 'unsigned' => (bool) $unsigned, + 'fixed' => (bool) $fixed, 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null, 'notnull' => (bool) ($tableColumn['null'] != 'YES'), 'scale' => null, diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index d51e5ad3700..b2b411564b5 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -199,7 +199,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) protected function _getPortableTableForeignKeysList($tableForeignKeys) { $list = array(); - foreach ($tableForeignKeys as $key => $value) { + foreach ($tableForeignKeys as $value) { $value = \array_change_key_case($value, CASE_LOWER); if (!isset($list[$value['constraint_name']])) { if ($value['delete_rule'] == "NO ACTION") {