Skip to content

Commit

Permalink
strict type
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Brzozowski committed Sep 9, 2018
1 parent c4bb800 commit d31cc26
Show file tree
Hide file tree
Showing 87 changed files with 340 additions and 85 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -35,10 +35,10 @@ install:

before_script:
- sudo mysql_upgrade
- travis_retry mysql -e 'CREATE DATABASE `podiumtest`;'
- travis_retry mysql -e 'CREATE DATABASE `migrationtest`;'
- mysql -e "SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';"
- mysql -e "CREATE USER 'podium'@'localhost' IDENTIFIED BY 'podium';"
- mysql -e "GRANT ALL PRIVILEGES ON podiumtest.* TO 'podium'@'localhost';"
- mysql -e "CREATE USER 'migration'@'localhost' IDENTIFIED BY 'migration';"
- mysql -e "GRANT ALL PRIVILEGES ON migrationtest.* TO 'migration'@'localhost';"

script:
- vendor/bin/phpunit --verbose $PHPUNIT_FLAGS
2 changes: 2 additions & 0 deletions Generator.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration;

use bizley\migration\table\TableColumn;
Expand Down
2 changes: 2 additions & 0 deletions Updater.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration;

use bizley\migration\table\TableChange;
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -15,6 +15,7 @@
},
"require": {
"php": ">=7.1.0",
"ext-mbstring": "*",
"yiisoft/yii2": ">=2.0.15.1 <2.1.0"
},
"require-dev": {
Expand Down
29 changes: 17 additions & 12 deletions controllers/MigrationController.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\controllers;

use bizley\migration\Generator;
Expand All @@ -22,13 +24,16 @@
* Generates migration file based on the existing database table and previous migrations.
*
* @author Paweł Bizley Brzozowski
* @version 3.0.0
* @version 3.0.2
* @license Apache 2.0
* https://github.com/bizley/yii2-migration
*/
class MigrationController extends Controller
{
protected $version = '3.0.0';
/**
* @var string
*/
protected $version = '3.0.2';

/**
* @var string Default command action.
Expand Down Expand Up @@ -100,7 +105,7 @@ class MigrationController extends Controller
/**
* @var bool|string|int Whether to use general column schema instead of database specific.
* Alias -g
* Since 2.3.0 this property is 1 by default.
* Since 3.0.0 this property is 1 by default.
* @since 2.0
*/
public $generalSchema = 1;
Expand Down Expand Up @@ -369,7 +374,7 @@ public function actionCreate($table): int

/**
* Creates new migrations for every table in database.
* Since 2.3.0 migration history table is skipped.
* Since 3.0.0 migration history table is skipped.
* @return int
* @since 2.1
*/
Expand All @@ -384,10 +389,10 @@ public function actionCreateAll(): int

$confirm = $this->confirm(' > Are you sure you want to generate ' . \count($tables) . ' migrations?', false);
if ($confirm) {
$this->actionCreate(implode(',', $tables));
} else {
$this->stdout("Operation cancelled by user.\n\n", Console::FG_YELLOW);
return $this->actionCreate(implode(',', $tables));
}

$this->stdout("Operation cancelled by user.\n\n", Console::FG_YELLOW);
return ExitCode::OK;
}

Expand Down Expand Up @@ -430,7 +435,7 @@ public function actionUpdate($table): int

/**
* Creates new update migrations for every table in database.
* Since 2.3.0 migration history table is skipped.
* Since 3.0.0 migration history table is skipped.
* @return int
* @since 2.1
*/
Expand All @@ -445,18 +450,18 @@ public function actionUpdateAll(): int

$confirm = $this->confirm(' > Are you sure you want to potentially generate ' . \count($tables) . ' migrations?', false);
if ($confirm) {
$this->actionUpdate(implode(',', $tables));
} else {
$this->stdout("Operation cancelled by user.\n\n", Console::FG_YELLOW);
return $this->actionUpdate(implode(',', $tables));
}

$this->stdout("Operation cancelled by user.\n\n", Console::FG_YELLOW);
return ExitCode::OK;
}

/**
* Removes migration history table name from the tables list.
* @param array $tables
* @return array
* @since 2.3.0
* @since 3.0.0
*/
public function removeMigrationTable($tables): array
{
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Expand Up @@ -6,7 +6,7 @@
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<testsuite name="Yii 2 Migration Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
Expand Down
2 changes: 2 additions & 0 deletions table/TableChange.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down
6 changes: 4 additions & 2 deletions table/TableColumn.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down Expand Up @@ -198,9 +200,9 @@ public function isColumnAppendPK($schema): bool
* @param TableStructure $table
* @param bool $primaryKey
* @param bool $autoIncrement
* @return string
* @return string|null
*/
public function prepareSchemaAppend($table, $primaryKey, $autoIncrement): string
public function prepareSchemaAppend($table, $primaryKey, $autoIncrement): ?string
{
switch ($table->schema) {
case TableStructure::SCHEMA_MSSQL:
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnBigInt.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnBigPK.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnBigUPK.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnBinary.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnBoolean.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnChar.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnDate.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnDateTime.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnDecimal.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnDouble.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnFactory.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\InvalidConfigException;
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnFloat.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnInt.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnJson.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnMoney.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnPK.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnSmallInt.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnString.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnText.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnTime.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnTimestamp.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnTinyInt.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableColumnUPK.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

/**
Expand Down
2 changes: 2 additions & 0 deletions table/TableForeignKey.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down
2 changes: 2 additions & 0 deletions table/TableIndex.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down
2 changes: 2 additions & 0 deletions table/TablePlan.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down
2 changes: 2 additions & 0 deletions table/TablePrimaryKey.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down
2 changes: 2 additions & 0 deletions table/TableStructure.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace bizley\migration\table;

use yii\base\BaseObject;
Expand Down

0 comments on commit d31cc26

Please sign in to comment.