Skip to content

fixed issue in enum fields generation #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/Xethron/MigrationsGenerator/Generators/FieldGenerator.php
Original file line number Diff line number Diff line change
@@ -73,8 +73,8 @@ protected function getEnum($table)
protected function setEnum(array $fields, $table)
{
foreach ($this->getEnum($table) as $column) {
$fields[$column->column_name]['type'] = 'enum';
$fields[$column->column_name]['args'] = str_replace('enum(', 'array(', $column->column_type);
$fields[$column->COLUMN_NAME]['type'] = 'enum';
$fields[$column->COLUMN_NAME]['args'] = str_replace('enum(', 'array(', $column->COLUMN_TYPE);
}
return $fields;
}
@@ -86,7 +86,7 @@ protected function setEnum(array $fields, $table)
*/
protected function getFields($columns, IndexGenerator $indexGenerator)
{
$fields = array();
$fields = [];
foreach ($columns as $column) {
$name = $column->getName();
$type = $column->getType()->getName();
@@ -242,7 +242,7 @@ protected function decorate($function, $args, $quotes = '\'')
*/
protected function getMultiFieldIndexes(IndexGenerator $indexGenerator)
{
$indexes = array();
$indexes = [];
foreach ($indexGenerator->getMultiFieldIndexes() as $index) {
$indexArray = [
'field' => $index->columns,
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ public function generate($table, $schema, $ignoreForeignKeyNames)

$foreignKeys = $schema->listTableForeignKeys($table);

if ( empty( $foreignKeys ) ) return array();
if ( empty( $foreignKeys ) ) return [];

foreach ( $foreignKeys as $foreignKey ) {
$fields[] = [
4 changes: 2 additions & 2 deletions src/Xethron/MigrationsGenerator/Generators/IndexGenerator.php
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@ class IndexGenerator {
*/
public function __construct($table, $schema, $ignoreIndexNames)
{
$this->indexes = array();
$this->multiFieldIndexes = array();
$this->indexes = [];
$this->multiFieldIndexes = [];
$this->ignoreIndexNames = $ignoreIndexNames;

$indexes = $schema->listTableIndexes( $table );
4 changes: 2 additions & 2 deletions src/Xethron/MigrationsGenerator/MigrateGenerateCommand.php
Original file line number Diff line number Diff line change
@@ -61,13 +61,13 @@ class MigrateGenerateCommand extends GeneratorCommand {
* Namely: Columns, Indexes and Foreign Keys
* @var array
*/
protected $fields = array();
protected $fields = [];

/**
* List of Migrations that has been done
* @var array
*/
protected $migrations = array();
protected $migrations = [];

/**
* @var bool
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ public function boot()
*/
public function provides()
{
return array();
return [];
}

}
2 changes: 1 addition & 1 deletion src/Xethron/MigrationsGenerator/Syntax/Table.php
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ public function run(array $fields, $table, $connection = null, $method = 'table'
*/
protected function getItems(array $items)
{
$result = array();
$result = [];
foreach($items as $item) {
$result[] = $this->getItem($item);
}