Skip to content
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

Changed migration template to adopt strict types #1819

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/Phinx/Migration/Migration.template.php.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
declare(strict_types=1);
dereuromark marked this conversation as resolved.
Show resolved Hide resolved
$namespaceDefinition
use $useClassName;

class $className extends $baseClassName
final class $className extends $baseClassName
{
/**
* Change Method.
Expand All @@ -15,7 +16,7 @@ class $className extends $baseClassName
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
public function change(): void
{

}
Expand Down
5 changes: 2 additions & 3 deletions tests/Phinx/Console/Command/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testCreateMigrationDefault(): void
$this->assertRegExp("/^[0-9]{14}.php/", $fileName);
$date = substr($fileName, 0, 14);
$this->assertFileExists($this->config->getMigrationPaths()[0]);
$prefix = "<?php\n\nuse Phinx\\Migration\\AbstractMigration;\n\nclass V{$date} extends AbstractMigration";
$prefix = "<?php\ndeclare(strict_types=1);\n\nuse Phinx\\Migration\\AbstractMigration;\n\nfinal class V{$date} extends AbstractMigration\n";
$this->assertStringStartsWith($prefix, file_get_contents($this->config->getMigrationPaths()[0] . DIRECTORY_SEPARATOR . $fileName));
}

Expand All @@ -125,9 +125,8 @@ public function testCreateMigrationWithName(): void
$this->assertCount(1, $files);
$fileName = current($files);
$this->assertRegExp("/^[0-9]{14}_my_migration.php/", $fileName);
$date = substr($fileName, 0, 14);
$this->assertFileExists($this->config->getMigrationPaths()[0]);
$prefix = "<?php\n\nuse Phinx\\Migration\\AbstractMigration;\n\nclass MyMigration extends AbstractMigration";
$prefix = "<?php\ndeclare(strict_types=1);\n\nuse Phinx\\Migration\\AbstractMigration;\n\nfinal class MyMigration extends AbstractMigration\n";
$this->assertStringStartsWith($prefix, file_get_contents($this->config->getMigrationPaths()[0] . DIRECTORY_SEPARATOR . $fileName));
}

Expand Down