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

Update the default migration template to adhere to PSR 12 formatting #875

Merged
merged 2 commits into from
Apr 19, 2021
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
12 changes: 6 additions & 6 deletions docs/en/reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ listens for all possible migrations events.

class MigrationsListener implements EventSubscriber
{
public function getSubscribedEvents() : array
public function getSubscribedEvents(): array
{
return [
Events::onMigrationsMigrating,
Expand All @@ -35,27 +35,27 @@ listens for all possible migrations events.
];
}

public function onMigrationsMigrating(MigrationsEventArgs $args) : void
public function onMigrationsMigrating(MigrationsEventArgs $args): void
{
// ...
}

public function onMigrationsMigrated(MigrationsEventArgs $args) : void
public function onMigrationsMigrated(MigrationsEventArgs $args): void
{
// ...
}

public function onMigrationsVersionExecuting(MigrationsVersionEventArgs $args) : void
public function onMigrationsVersionExecuting(MigrationsVersionEventArgs $args): void
{
// ...
}

public function onMigrationsVersionExecuted(MigrationsVersionEventArgs $args) : void
public function onMigrationsVersionExecuted(MigrationsVersionEventArgs $args): void
{
// ...
}

public function onMigrationsVersionSkipped(MigrationsVersionEventArgs $args) : void
public function onMigrationsVersionSkipped(MigrationsVersionEventArgs $args): void
{
// ...
}
Expand Down
12 changes: 6 additions & 6 deletions docs/en/reference/generating-migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ the ORM. To test this functionality, create a new ``User`` entity located at ``l
$this->id = $id;
}

public function getId() : ?int
public function getId(): ?int
{
return $this->id;
}

public function setUsername(string $username) : void
public function setUsername(string $username): void
{
$this->username = $username;
}

public function getUsername() : ?string
public function getUsername(): ?string
{
return $this->username;
}
Expand Down Expand Up @@ -95,12 +95,12 @@ Take a look at the generated migration:
*/
final class Version20180601215504 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return '';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
Expand All @@ -109,7 +109,7 @@ Take a look at the generated migration:
$this->addSql('DROP TABLE example_table');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
Expand Down
6 changes: 3 additions & 3 deletions docs/en/reference/managing-migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ is, it does not have anything in it so nothing would be executed! Let's add some
*/
final class Version20180601193057 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return 'This is my example migration.';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE example_table (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE example_table');
}
Expand Down
30 changes: 15 additions & 15 deletions docs/en/reference/migration-classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ migration looks like:
*/
final class Version20180601193057 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return '';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs

}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs

Expand All @@ -62,7 +62,7 @@ Override this method if you want to disable transactions in a migration. It defa

.. code-block:: php

public function isTransactional() : bool
public function isTransactional(): bool
{
return false;
}
Expand All @@ -85,7 +85,7 @@ will get outputted when you run the ``./vendor/bin/doctrine-migrations status --

.. code-block:: php

public function getDescription() : string
public function getDescription(): string
{
return 'The description of my awesome migration!';
}
Expand All @@ -97,7 +97,7 @@ This method gets called before the ``up()`` is called.

.. code-block:: php

public function preUp(Schema $schema) : void
public function preUp(Schema $schema): void
{
}

Expand All @@ -108,7 +108,7 @@ This method gets called after the ``up()`` is called.

.. code-block:: php

public function postUp(Schema $schema) : void
public function postUp(Schema $schema): void
{
}

Expand All @@ -119,7 +119,7 @@ This method gets called before the ``down()`` is called.

.. code-block:: php

public function preDown(Schema $schema) : void
public function preDown(Schema $schema): void
{
}

Expand All @@ -130,7 +130,7 @@ This method gets called after the ``down()`` is called.

.. code-block:: php

public function postDown(Schema $schema) : void
public function postDown(Schema $schema): void
{
}

Expand All @@ -146,7 +146,7 @@ Warn with a message if some condition is met.

.. code-block:: php

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->warnIf(true, 'Something might be going wrong');

Expand All @@ -160,7 +160,7 @@ Abort the migration if some condition is met:

.. code-block:: php

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->abortIf(true, 'Something went wrong. Aborting.');

Expand All @@ -174,7 +174,7 @@ Skip the migration if some condition is met.

.. code-block:: php

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->skipIf(true, 'Skipping this migration.');

Expand All @@ -191,7 +191,7 @@ to the addSql method as parameters.

.. code-block:: php

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$users = [
['name' => 'mike', 'id' => 1],
Expand All @@ -211,7 +211,7 @@ Write some debug information to the console.

.. code-block:: php

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->write('Doing some cool migration!');

Expand All @@ -226,7 +226,7 @@ The ``throwIrreversibleMigrationException`` method accepts an optional message t

.. code-block:: php

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException();

Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/Migrations/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ class Generator
*/
final class <className> extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return '';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
<up>
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
<down>
Expand Down