Skip to content

Commit f34fc58

Browse files
committed
refactor: rename variable names when DROP column
1 parent 4ac6ca5 commit f34fc58

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

system/Database/Forge.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -755,15 +755,16 @@ public function addColumn(string $table, $field): bool
755755
}
756756

757757
/**
758-
* @param array|string $columnName
758+
* @param array|string $columnNames column names to DROP
759759
*
760-
* @return mixed
760+
* @return bool
761761
*
762762
* @throws DatabaseException
763763
*/
764-
public function dropColumn(string $table, $columnName)
764+
public function dropColumn(string $table, $columnNames)
765765
{
766-
$sql = $this->_alterTable('DROP', $this->db->DBPrefix . $table, $columnName);
766+
$sql = $this->_alterTable('DROP', $this->db->DBPrefix . $table, $columnNames);
767+
767768
if ($sql === false) {
768769
if ($this->db->DBDebug) {
769770
throw new DatabaseException('This feature is not available for the database you are using.');
@@ -819,22 +820,26 @@ public function modifyColumn(string $table, $field): bool
819820
/**
820821
* @param 'ADD'|'CHANGE'|'DROP' $alterType
821822
* @param array|string $processedFields Processed column definitions
823+
* or column names to DROP
822824
*
823-
* @return false|string|string[]
825+
* @return list<string>|string SQL string
826+
* @phpstan-return ($alterType is 'DROP' ? string : list<string>)
824827
*/
825828
protected function _alterTable(string $alterType, string $table, $processedFields)
826829
{
827830
$sql = 'ALTER TABLE ' . $this->db->escapeIdentifiers($table) . ' ';
828831

829832
// DROP has everything it needs now.
830833
if ($alterType === 'DROP') {
831-
if (is_string($processedFields)) {
832-
$processedFields = explode(',', $processedFields);
834+
$columnNamesToDrop = $processedFields;
835+
836+
if (is_string($columnNamesToDrop)) {
837+
$columnNamesToDrop = explode(',', $columnNamesToDrop);
833838
}
834839

835-
$processedFields = array_map(fn ($field) => 'DROP COLUMN ' . $this->db->escapeIdentifiers(trim($field)), $processedFields);
840+
$columnNamesToDrop = array_map(fn ($field) => 'DROP COLUMN ' . $this->db->escapeIdentifiers(trim($field)), $columnNamesToDrop);
836841

837-
return $sql . implode(', ', $processedFields);
842+
return $sql . implode(', ', $columnNamesToDrop);
838843
}
839844

840845
$sql .= ($alterType === 'ADD') ? 'ADD ' : $alterType . ' COLUMN ';

0 commit comments

Comments
 (0)