Skip to content

Commit

Permalink
Merge d363589 into b8550bf
Browse files Browse the repository at this point in the history
  • Loading branch information
skie committed Jun 4, 2019
2 parents b8550bf + d363589 commit af2c6a1
Show file tree
Hide file tree
Showing 67 changed files with 792 additions and 751 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php

php:
- 5.6
- 7.0
- 7.2
- 7.3

sudo: false
Expand All @@ -21,7 +20,7 @@ matrix:
fast_finish: true

include:
- php: 5.6
- php: 7.2
dist: trusty
sudo: required
env: DB=mysql db_dsn='mysql://root@127.0.0.1/cakephp_test?encoding=utf8mb4' DBV=56 db_dsn_compare='mysql://root@127.0.0.1/cakephp_comparisons'
Expand All @@ -32,16 +31,16 @@ matrix:
- mysql-client-core-5.6
- mysql-client-5.6

- php: 5.6
- php: 7.2
env: DB=pgsql db_dsn='postgres://postgres@127.0.0.1/cakephp_test' db_dsn_compare='postgres://postgres@127.0.0.1/cakephp_comparisons'

- php: 7.0
- php: 7.2
env: DB=pgsql db_dsn='postgres://postgres@127.0.0.1/cakephp_test' db_dsn_compare='postgres://postgres@127.0.0.1/cakephp_comparisons'

- php: 5.6
- php: 7.2
env: PREFER_LOWEST=1

- php: 7.2
- php: 7.3
dist: trusty
sudo: required
env: CODECOVERAGE=1 DEFAULT=0 DB=mysql db_dsn='mysql://root@127.0.0.1/cakephp_test?encoding=utf8mb4' DBV=56 db_dsn_compare='mysql://root@127.0.0.1/cakephp_comparisons'
Expand All @@ -52,7 +51,7 @@ matrix:
- mysql-client-core-5.6
- mysql-client-5.6

- php: 7.2
- php: 7.3
env: CHECKS=1 DEFAULT=0

before_script:
Expand Down
26 changes: 15 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
"source": "https://github.com/cakephp/migrations"
},
"require": {
"php": ">=5.6.0",
"robmorgan/phinx": "^0.10.3",
"cakephp/orm": "^3.6.0",
"cakephp/cache": "^3.6.0"
"php": ">=7.2.0",
"robmorgan/phinx": "cake4-dev",
"cakephp/orm": "4.x-dev",
"cakephp/cache": "4.x-dev"
},
"require-dev": {
"phpunit/phpunit": "^5.7.14|^6.0",
"cakephp/cakephp": "^3.6.0",
"cakephp/bake": "^1.7.0",
"cakephp/cakephp-codesniffer": "^3.0"
"phpunit/phpunit": "^8.0",
"cakephp/cakephp": "4.x-dev as 4.0.0",
"cakephp/bake": "4.x-dev",
"cakephp/cakephp-codesniffer": "dev-next"
},
"autoload": {
"psr-4": {
Expand All @@ -51,11 +51,15 @@
"scripts": {
"check": [
"@cs-check",
"@test"
"@test",
"@stan"
],
"cs-check": "phpcs --colors -p ./src ./tests",
"cs-fix": "phpcbf --colors ./src ./tests",
"cs-check": "phpcs -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"cs-fix": "phpcbf --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"stan": "phpstan analyse src/ && psalm --show-info=false",
"psalm": "psalm --show-info=false",
"test": "phpunit",
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.11 vimeo/psalm:^3.0 && mv composer.backup composer.json",
"test-coverage": "phpunit --coverage-clover=clover.xml"
}
}
29 changes: 17 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>

Expand All @@ -26,22 +25,28 @@
</listener>
</listeners>

<!-- Prevent coverage reports from looking in tests and vendors -->
<filter>
<blacklist>
<directory suffix=".php">./vendor/</directory>
<directory suffix=".ctp">./vendor/</directory>

<directory suffix=".php">./tests/</directory>
<directory suffix=".ctp">./tests/</directory>
</blacklist>
</filter>

<!-- Prevent coverage reports from looking in tests, vendors, config folders -->
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>

<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>

<!-- SQLite
<env name="db_dsn" value="sqlite:///:memory:"/>
-->
<!-- Postgres
<env name="db_dsn" value="postgres://localhost/cake_test?timezone=UTC"/>
-->
<!-- Mysql
<env name="db_dsn" value="mysql://localhost/cake_test?timezone=UTC"/>
-->
<!-- SQL Server
<env name="db_dsn" value="sqlserver://localhost/cake_test?timezone=UTC"/>
-->
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/ConfigurationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getConfig($forceRefresh = false)
$connectionConfig = ConnectionManager::getConfig($connection);
$adapterName = $this->getAdapterName($connectionConfig['driver']);

$templatePath = __DIR__ . DS . 'Template' . DS;
$templatePath = dirname(__DIR__) . DS . 'templates' . DS;
$config = [
'paths' => [
'migrations' => $migrationsPath,
Expand Down
5 changes: 3 additions & 2 deletions src/Shell/MigrationsShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
namespace Migrations\Shell;

use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell;
use Migrations\MigrationsDispatcher;
use Symfony\Component\Console\Input\ArgvInput;
Expand Down Expand Up @@ -57,7 +58,7 @@ class MigrationsShell extends Shell
*
* @return \Cake\Console\ConsoleOptionParser
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
return parent::getOptionParser()
->addOption('plugin', ['short' => 'p'])
Expand All @@ -83,7 +84,7 @@ public function getOptionParser()
*
* @return void
*/
public function initialize()
public function initialize(): void
{
if (!defined('PHINX_VERSION')) {
define('PHINX_VERSION', (0 === strpos('@PHINX_VERSION@', '@PHINX_VERSION')) ? '0.4.3' : '@PHINX_VERSION@');
Expand Down
3 changes: 2 additions & 1 deletion src/Shell/Task/CommandTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
namespace Migrations\Shell\Task;

use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell;

/**
Expand All @@ -26,7 +27,7 @@ class CommandTask extends Shell
/**
* {@inheritDoc}
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();
$parser
Expand Down
3 changes: 2 additions & 1 deletion src/Shell/Task/CreateTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
namespace Migrations\Shell\Task;

use Cake\Console\ConsoleOptionParser;
use Phinx\Console\Command\Create;

/**
Expand All @@ -26,7 +27,7 @@ class CreateTask extends CommandTask
/**
* {@inheritDoc}
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();
$parser
Expand Down
4 changes: 3 additions & 1 deletion src/Shell/Task/DumpTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
namespace Migrations\Shell\Task;

use Cake\Console\ConsoleOptionParser;

/**
* This task class is needed in order to provide a correct autocompletion feature
* when using the CakePHP migrations shell plugin. It has no effect on the
Expand All @@ -24,7 +26,7 @@ class DumpTask extends CommandTask
/**
* {@inheritDoc}
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();
$parser
Expand Down
4 changes: 3 additions & 1 deletion src/Shell/Task/MarkMigratedTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
namespace Migrations\Shell\Task;

use Cake\Console\ConsoleOptionParser;

/**
* This task class is needed in order to provide a correct autocompletion feature
* when using the CakePHP migrations shell plugin. It has no effect on the
Expand All @@ -24,7 +26,7 @@ class MarkMigratedTask extends CommandTask
/**
* {@inheritDoc}
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();
$parser
Expand Down
4 changes: 3 additions & 1 deletion src/Shell/Task/MigrateTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
namespace Migrations\Shell\Task;

use Cake\Console\ConsoleOptionParser;

/**
* This task class is needed in order to provide a correct autocompletion feature
* when using the CakePHP migrations shell plugin. It has no effect on the
Expand All @@ -24,7 +26,7 @@ class MigrateTask extends CommandTask
/**
* {@inheritDoc}
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();
$parser
Expand Down
22 changes: 11 additions & 11 deletions src/Shell/Task/MigrationDiffTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
namespace Migrations\Shell\Task;

use Cake\Core\Configure;
use Cake\Database\Schema\Table;
use Cake\Console\ConsoleOptionParser;
use Cake\Database\Schema\TableSchema;
use Cake\Datasource\ConnectionManager;
use Cake\Event\Event;
use Cake\Event\EventManager;
Expand All @@ -24,7 +25,6 @@
/**
* Task class for generating migration diff files.
*
* @property \Bake\Shell\Task\BakeTemplateTask $BakeTemplate
* @property \Bake\Shell\Task\TestTask $Test
*/
class MigrationDiffTask extends SimpleMigrationTask
Expand Down Expand Up @@ -68,15 +68,15 @@ class MigrationDiffTask extends SimpleMigrationTask
protected $tables = [];

/**
* Array of \Cake\Database\Schema\Table objects from the dump file which
* Array of \Cake\Database\Schema\TableSchema objects from the dump file which
* represents the state of the database after the last migrate / rollback command
*
* @var array
*/
protected $dumpSchema;

/**
* Array of \Cake\Database\Schema\Table objects from the current state of the database
* Array of \Cake\Database\Schema\TableSchema objects from the current state of the database
*
* @var array
*/
Expand All @@ -97,7 +97,7 @@ class MigrationDiffTask extends SimpleMigrationTask
/**
* {@inheritDoc}
*/
public function bake($name)
public function bake(string $name): string
{
$this->setup();

Expand Down Expand Up @@ -168,7 +168,7 @@ public function getCollection($connection)
*
* @return array
*/
public function templateData()
public function templateData(): array
{
$this->dumpSchema = $this->getDumpSchema();
$this->currentSchema = $this->getCurrentSchema();
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function calculateDiff()

/**
* Calculate the diff between the current state of the database and the schema dump
* by returning an array containing the full \Cake\Database\Schema\Table definitions
* by returning an array containing the full \Cake\Database\Schema\TableSchema definitions
* of tables to be created and removed in the diff file.
*
* The method directly sets the diff in a property of the class.
Expand Down Expand Up @@ -328,7 +328,7 @@ protected function getConstraints()
$this->templateData[$table]['constraints']['add'][$constraintName] =
$currentSchema->getConstraint($constraintName);
$constraint = $currentSchema->getConstraint($constraintName);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) {
$this->templateData[$table]['constraints']['add'][$constraintName] = $constraint;
} else {
$this->templateData[$table]['indexes']['add'][$constraintName] = $constraint;
Expand All @@ -354,7 +354,7 @@ protected function getConstraints()
$removedConstraints = array_diff($oldConstraints, $currentConstraints);
foreach ($removedConstraints as $constraintName) {
$constraint = $this->dumpSchema[$table]->getConstraint($constraintName);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) {
$this->templateData[$table]['constraints']['remove'][$constraintName] = $constraint;
} else {
$this->templateData[$table]['indexes']['remove'][$constraintName] = $constraint;
Expand Down Expand Up @@ -534,7 +534,7 @@ protected function getCurrentSchema()
/**
* {@inheritDoc}
*/
public function template()
public function template(): string
{
return 'Migrations.config/diff';
}
Expand All @@ -544,7 +544,7 @@ public function template()
*
* @return \Cake\Console\ConsoleOptionParser
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
$parser = parent::getOptionParser();

Expand Down
Loading

0 comments on commit af2c6a1

Please sign in to comment.