From e2803d21774017dc897df3b93f1d4ce6275392ff Mon Sep 17 00:00:00 2001 From: SerafimArts Date: Tue, 12 Oct 2021 12:59:56 +0300 Subject: [PATCH 1/5] Change precondition contracts to Spiral namespace. --- resources/.phpstorm.meta.php | 119 +++++++++---------- src/Atomizer/Atomizer.php | 13 +- src/Atomizer/Renderer.php | 47 ++++---- src/Atomizer/RendererInterface.php | 29 +++-- src/Capsule.php | 14 ++- src/Exception/AtomizerException.php | 16 --- src/FileRepository.php | 16 ++- src/Migration.php | 13 +- src/Migration/DefinitionInterface.php | 6 +- src/Migration/ProvidesSyncStateInterface.php | 6 +- src/Migrator.php | 38 +++--- src/Migrator/MigrationsTable.php | 6 +- src/MigratorInterface.php | 19 ++- src/Operation/AbstractOperation.php | 2 +- src/Operation/Column/Add.php | 6 +- src/Operation/Column/Alter.php | 6 +- src/Operation/Column/Column.php | 10 +- src/Operation/Column/Drop.php | 6 +- src/Operation/Column/Rename.php | 6 +- src/Operation/ForeignKey/Add.php | 6 +- src/Operation/ForeignKey/Alter.php | 6 +- src/Operation/ForeignKey/Drop.php | 6 +- src/Operation/Index/Add.php | 6 +- src/Operation/Index/Alter.php | 6 +- src/Operation/Index/Drop.php | 6 +- src/Operation/Table/Create.php | 6 +- src/Operation/Table/Drop.php | 6 +- src/Operation/Table/PrimaryKeys.php | 6 +- src/Operation/Table/Rename.php | 6 +- src/Operation/Table/Update.php | 6 +- src/OperationInterface.php | 7 +- src/RepositoryInterface.php | 5 +- src/TableBlueprint.php | 15 ++- 33 files changed, 232 insertions(+), 239 deletions(-) delete mode 100644 src/Exception/AtomizerException.php diff --git a/resources/.phpstorm.meta.php b/resources/.phpstorm.meta.php index 5ff2ad9..071aef7 100644 --- a/resources/.phpstorm.meta.php +++ b/resources/.phpstorm.meta.php @@ -12,77 +12,77 @@ namespace Spiral\Migrations { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\CapsuleInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\CapsuleInterface instead. */ interface CapsuleInterface extends \Cycle\Migrations\CapsuleInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\MigrationInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\MigrationInterface instead. */ interface MigrationInterface extends \Cycle\Migrations\MigrationInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\MigratorInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\MigratorInterface instead. */ interface MigratorInterface extends \Cycle\Migrations\MigratorInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\OperationInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\OperationInterface instead. */ interface OperationInterface extends \Cycle\Migrations\OperationInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\RepositoryInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\RepositoryInterface instead. */ interface RepositoryInterface extends \Cycle\Migrations\RepositoryInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Capsule instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Capsule instead. */ final class Capsule extends \Cycle\Migrations\Capsule { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\FileRepository instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\FileRepository instead. */ final class FileRepository extends \Cycle\Migrations\FileRepository { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Migrator instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migrator instead. */ final class Migrator extends \Cycle\Migrations\Migrator { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\State instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\State instead. */ final class State extends \Cycle\Migrations\State { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\TableBlueprint instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\TableBlueprint instead. */ final class TableBlueprint extends \Cycle\Migrations\TableBlueprint { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Migration instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migration instead. */ abstract class Migration extends \Cycle\Migrations\Migration { @@ -92,7 +92,7 @@ abstract class Migration extends \Cycle\Migrations\Migration namespace Spiral\Migrations\Operation { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\AbstractOperation instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\AbstractOperation instead. */ abstract class AbstractOperation extends \Cycle\Migrations\Operation\AbstractOperation { @@ -102,35 +102,35 @@ abstract class AbstractOperation extends \Cycle\Migrations\Operation\AbstractOpe namespace Spiral\Migrations\Operation\Column { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Column\Add instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Column\Add instead. */ final class Add extends \Cycle\Migrations\Operation\Column\Add { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Column\Alter instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Column\Alter instead. */ final class Alter extends \Cycle\Migrations\Operation\Column\Alter { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Column\Drop instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Column\Drop instead. */ final class Drop extends \Cycle\Migrations\Operation\Column\Drop { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Column\Rename instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Column\Rename instead. */ final class Rename extends \Cycle\Migrations\Operation\Column\Rename { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Column\Column instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Column\Column instead. */ abstract class Column extends \Cycle\Migrations\Operation\Column\Column { @@ -140,28 +140,28 @@ abstract class Column extends \Cycle\Migrations\Operation\Column\Column namespace Spiral\Migrations\Operation\ForeignKey { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\ForeignKey\Add instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\ForeignKey\Add instead. */ final class Add extends \Cycle\Migrations\Operation\ForeignKey\Add { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\ForeignKey\Alter instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\ForeignKey\Alter instead. */ final class Alter extends \Cycle\Migrations\Operation\ForeignKey\Alter { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\ForeignKey\Drop instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\ForeignKey\Drop instead. */ final class Drop extends \Cycle\Migrations\Operation\ForeignKey\Drop { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\ForeignKey\ForeignKey instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\ForeignKey\ForeignKey instead. */ abstract class ForeignKey extends \Cycle\Migrations\Operation\ForeignKey\ForeignKey { @@ -171,28 +171,28 @@ abstract class ForeignKey extends \Cycle\Migrations\Operation\ForeignKey\Foreign namespace Spiral\Migrations\Operation\Index { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Index\Add instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Index\Add instead. */ final class Add extends \Cycle\Migrations\Operation\Index\Add { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Index\Alter instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Index\Alter instead. */ final class Alter extends \Cycle\Migrations\Operation\Index\Alter { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Index\Drop instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Index\Drop instead. */ final class Drop extends \Cycle\Migrations\Operation\Index\Drop { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Index\Index instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Index\Index instead. */ abstract class Index extends \Cycle\Migrations\Operation\Index\Index { @@ -202,35 +202,35 @@ abstract class Index extends \Cycle\Migrations\Operation\Index\Index namespace Spiral\Migrations\Operation\Table { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Table\Create instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Table\Create instead. */ final class Create extends \Cycle\Migrations\Operation\Table\Create { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Table\Drop instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Table\Drop instead. */ final class Drop extends \Cycle\Migrations\Operation\Table\Drop { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Table\PrimaryKeys instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Table\PrimaryKeys instead. */ final class PrimaryKeys extends \Cycle\Migrations\Operation\Table\PrimaryKeys { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Table\Rename instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Table\Rename instead. */ final class Rename extends \Cycle\Migrations\Operation\Table\Rename { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Table\Update instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Table\Update instead. */ final class Update extends \Cycle\Migrations\Operation\Table\Update { @@ -240,7 +240,7 @@ final class Update extends \Cycle\Migrations\Operation\Table\Update namespace Spiral\Migrations\Operation\Traits { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Traits\OptionsTrait instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Operation\Traits\OptionsTrait instead. */ trait OptionsTrait { @@ -251,90 +251,83 @@ trait OptionsTrait namespace Spiral\Migrations\Migrator { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Migrator\MigrationsTable instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migrator\MigrationsTable instead. */ class MigrationsTable extends \Cycle\Migrations\Migrator\MigrationsTable { } } -namespace Spiral\Migrations\Operation\Migration { +namespace Spiral\Migrations\Migration { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Migration\DefinitionInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migration\DefinitionInterface instead. */ - interface DefinitionInterface extends \Cycle\Migrations\Operation\Migration\DefinitionInterface + interface DefinitionInterface extends \Cycle\Migrations\Migration\DefinitionInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Migration\ProvidesSyncStateInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migration\ProvidesSyncStateInterface instead. */ - interface ProvidesSyncStateInterface extends \Cycle\Migrations\Operation\Migration\ProvidesSyncStateInterface + interface ProvidesSyncStateInterface extends \Cycle\Migrations\Migration\ProvidesSyncStateInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Migration\State instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migration\State instead. */ - class State extends \Cycle\Migrations\Operation\Migration\State + class State extends \Cycle\Migrations\Migration\State { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Operation\Migration\Status instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Migration\Status instead. */ - final class Status extends \Cycle\Migrations\Operation\Migration\Status + final class Status extends \Cycle\Migrations\Migration\Status { } } -namespace Spiral\Migrations\Operation\Exception { +namespace Spiral\Migrations\Exception { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\AtomizerException instead. - */ - class AtomizerException extends \Cycle\Migrations\Exception\AtomizerException - { - } - - /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\BlueprintException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\BlueprintException instead. */ class BlueprintException extends \Cycle\Migrations\Exception\BlueprintException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\CapsuleException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\CapsuleException instead. */ class CapsuleException extends \Cycle\Migrations\Exception\CapsuleException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\ContextException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\ContextException instead. */ class ContextException extends \Cycle\Migrations\Exception\ContextException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\MigrationException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\MigrationException instead. */ class MigrationException extends \Cycle\Migrations\Exception\MigrationException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\OperationException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\OperationException instead. */ class OperationException extends \Cycle\Migrations\Exception\OperationException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\RepositoryException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\RepositoryException instead. */ class RepositoryException extends \Cycle\Migrations\Exception\RepositoryException { @@ -344,28 +337,28 @@ class RepositoryException extends \Cycle\Migrations\Exception\RepositoryExceptio namespace Spiral\Migrations\Operation\Exception\Operation { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\Operation\ColumnException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\Operation\ColumnException instead. */ class ColumnException extends \Cycle\Migrations\Exception\Operation\ColumnException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\Operation\ForeignKeyException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\Operation\ForeignKeyException instead. */ class ForeignKeyException extends \Cycle\Migrations\Exception\Operation\ForeignKeyException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\Operation\IndexException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\Operation\IndexException instead. */ class IndexException extends \Cycle\Migrations\Exception\Operation\IndexException { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Exception\Operation\TableException instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Exception\Operation\TableException instead. */ class TableException extends \Cycle\Migrations\Exception\Operation\TableException { @@ -375,7 +368,7 @@ class TableException extends \Cycle\Migrations\Exception\Operation\TableExceptio namespace Spiral\Migrations\Config { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Config\MigrationConfig instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Config\MigrationConfig instead. */ final class MigrationConfig extends \Cycle\Migrations\Config\MigrationConfig { @@ -385,21 +378,21 @@ final class MigrationConfig extends \Cycle\Migrations\Config\MigrationConfig namespace Spiral\Migrations\Atomizer { /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Atomizer\RendererInterface instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Atomizer\RendererInterface instead. */ interface RendererInterface extends \Cycle\Migrations\Atomizer\RendererInterface { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Atomizer\Atomizer instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Atomizer\Atomizer instead. */ final class Atomizer extends \Cycle\Migrations\Atomizer\Atomizer { } /** - * @deprecated Since Cycle ORM 1.0, use Cycle\Migrations\Atomizer\Renderer instead. + * @deprecated since cycle/migrations 1.0, use Cycle\Migrations\Atomizer\Renderer instead. */ final class Renderer extends \Cycle\Migrations\Atomizer\Renderer { diff --git a/src/Atomizer/Atomizer.php b/src/Atomizer/Atomizer.php index 8b73f13..c1377f4 100644 --- a/src/Atomizer/Atomizer.php +++ b/src/Atomizer/Atomizer.php @@ -11,7 +11,9 @@ namespace Cycle\Migrations\Atomizer; +use Spiral\Migrations\Atomizer\RendererInterface as SpiralRendererInterface; use Cycle\Database\Schema\AbstractTable; +use Spiral\Database\Schema\AbstractTable as SpiralAbstractTable; use Cycle\Database\Schema\Reflector; use Spiral\Reactor\Partial\Source; @@ -28,9 +30,10 @@ final class Atomizer private $renderer; /** - * @param RendererInterface $renderer + * @param SpiralRendererInterface|RendererInterface $renderer This argument + * signature will be changed to {@see RendererInterface} in further release. */ - public function __construct(RendererInterface $renderer) + public function __construct(SpiralRendererInterface $renderer) { $this->renderer = $renderer; } @@ -38,11 +41,11 @@ public function __construct(RendererInterface $renderer) /** * Add new table into atomizer. * - * @param AbstractTable $table - * + * @param SpiralAbstractTable|AbstractTable $table This argument signature + * will be changed to {@see AbstractTable} in further release. * @return Atomizer */ - public function addTable(AbstractTable $table): self + public function addTable(SpiralAbstractTable $table): self { $this->tables[] = $table; diff --git a/src/Atomizer/Renderer.php b/src/Atomizer/Renderer.php index 9135002..be0de80 100644 --- a/src/Atomizer/Renderer.php +++ b/src/Atomizer/Renderer.php @@ -15,6 +15,7 @@ use Cycle\Database\Schema\AbstractForeignKey; use Cycle\Database\Schema\AbstractIndex; use Cycle\Database\Schema\AbstractTable; +use Spiral\Database\Schema\AbstractTable as SpiralAbstractTable; use Cycle\Database\Schema\Comparator; use Spiral\Reactor\Partial\Source; use Spiral\Reactor\Serializer; @@ -31,15 +32,11 @@ final class Renderer implements RendererInterface public const ORIGINAL_STATE = 1; /** - * {@inheritdoc} + * {@inheritDoc} */ - public function createTable(Source $source, AbstractTable $table): void + public function createTable(Source $source, SpiralAbstractTable $table): void { - $this->render( - $source, - '$this->table(%s)', - $table - ); + $this->render($source, '$this->table(%s)', $table); $comparator = $table->getComparator(); $this->declareColumns($source, $comparator); @@ -59,9 +56,9 @@ public function createTable(Source $source, AbstractTable $table): void } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function updateTable(Source $source, AbstractTable $table): void + public function updateTable(Source $source, SpiralAbstractTable $table): void { $this->render( $source, @@ -87,9 +84,9 @@ public function updateTable(Source $source, AbstractTable $table): void } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function revertTable(Source $source, AbstractTable $table): void + public function revertTable(Source $source, SpiralAbstractTable $table): void { //Get table blueprint $this->render( @@ -108,9 +105,9 @@ public function revertTable(Source $source, AbstractTable $table): void } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function dropTable(Source $source, AbstractTable $table): void + public function dropTable(Source $source, SpiralAbstractTable $table): void { $this->render( $source, @@ -370,7 +367,8 @@ protected function alterColumn( * * @param Source $source * @param string $format - * @param array ...$values + * @param array ...$values + * @throws \ReflectionException */ protected function render(Source $source, string $format, ...$values): void { @@ -416,10 +414,10 @@ protected function render(Source $source, string $format, ...$values): void } /** - * @param Serializer $serializer + * @param Serializer $serializer * @param AbstractColumn $column - * * @return string + * @throws \ReflectionException */ private function columnOptions(Serializer $serializer, AbstractColumn $column): string { @@ -445,10 +443,10 @@ private function columnOptions(Serializer $serializer, AbstractColumn $column): } /** - * @param Serializer $serializer + * @param Serializer $serializer * @param AbstractIndex $index - * * @return string + * @throws \ReflectionException */ private function indexOptions(Serializer $serializer, AbstractIndex $index): string { @@ -463,15 +461,13 @@ private function indexOptions(Serializer $serializer, AbstractIndex $index): str } /** - * @param Serializer $serializer + * @param Serializer $serializer * @param AbstractForeignKey $reference - * * @return string + * @throws \ReflectionException */ - private function foreignKeyOptions( - Serializer $serializer, - AbstractForeignKey $reference - ): string { + private function foreignKeyOptions(Serializer $serializer, AbstractForeignKey $reference): string + { return $this->mountIndents( $serializer->serialize( [ @@ -486,8 +482,7 @@ private function foreignKeyOptions( /** * Mount indents for column and index options. * - * @param $serialized - * + * @param string $serialized * @return string */ private function mountIndents(string $serialized): string diff --git a/src/Atomizer/RendererInterface.php b/src/Atomizer/RendererInterface.php index 7c3ae39..fb24bdc 100644 --- a/src/Atomizer/RendererInterface.php +++ b/src/Atomizer/RendererInterface.php @@ -12,6 +12,7 @@ namespace Cycle\Migrations\Atomizer; use Cycle\Database\Schema\AbstractTable; +use Spiral\Database\Schema\AbstractTable as SpiralAbstractTable; use Spiral\Reactor\Partial\Source; /** @@ -22,32 +23,36 @@ interface RendererInterface /** * Migration engine specific table creation syntax. * - * @param Source $source - * @param AbstractTable $table + * @param Source $source + * @param SpiralAbstractTable|AbstractTable $table This argument signature + * will be changed to {@see AbstractTable} in further release. */ - public function createTable(Source $source, AbstractTable $table); + public function createTable(Source $source, SpiralAbstractTable $table); /** * Migration engine specific table update syntax. * - * @param Source $source - * @param AbstractTable $table + * @param Source $source + * @param SpiralAbstractTable|AbstractTable $table This argument signature + * will be changed to {@see AbstractTable} in further release. */ - public function updateTable(Source $source, AbstractTable $table); + public function updateTable(Source $source, SpiralAbstractTable $table); /** * Migration engine specific table revert syntax. * - * @param Source $source - * @param AbstractTable $table + * @param Source $source + * @param SpiralAbstractTable|AbstractTable $table This argument signature + * will be changed to {@see AbstractTable} in further release. */ - public function revertTable(Source $source, AbstractTable $table); + public function revertTable(Source $source, SpiralAbstractTable $table); /** * Migration engine specific table drop syntax. * - * @param Source $source - * @param AbstractTable $table + * @param Source $source + * @param SpiralAbstractTable $table This argument signature will be changed + * to {@see AbstractTable} in further release. */ - public function dropTable(Source $source, AbstractTable $table); + public function dropTable(Source $source, SpiralAbstractTable $table); } diff --git a/src/Capsule.php b/src/Capsule.php index ac1359a..b1dfac5 100644 --- a/src/Capsule.php +++ b/src/Capsule.php @@ -12,6 +12,7 @@ namespace Cycle\Migrations; use Cycle\Database\Database; +use Spiral\Database\Database as SpiralDatabase; use Cycle\Database\DatabaseInterface; use Cycle\Database\DatabaseManager; use Cycle\Database\Schema\AbstractTable; @@ -30,15 +31,16 @@ final class Capsule implements CapsuleInterface private $schemas = []; /** - * @param Database $database + * @param SpiralDatabase|Database $database This argument signature will be + * changed to {@see Database} in further release. */ - public function __construct(Database $database) + public function __construct(SpiralDatabase $database) { $this->database = $database; } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getDatabase(): DatabaseInterface { @@ -46,7 +48,7 @@ public function getDatabase(): DatabaseInterface } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getTable(string $table): TableInterface { @@ -54,7 +56,7 @@ public function getTable(string $table): TableInterface } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getSchema(string $table): AbstractTable { @@ -67,7 +69,7 @@ public function getSchema(string $table): AbstractTable } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws \Throwable */ diff --git a/src/Exception/AtomizerException.php b/src/Exception/AtomizerException.php deleted file mode 100644 index 5574724..0000000 --- a/src/Exception/AtomizerException.php +++ /dev/null @@ -1,16 +0,0 @@ -config = $config; $this->files = new Files(); $this->factory = $factory ?? new Container(); - $this->inflector = (new \Doctrine\Inflector\Rules\English\InflectorFactory())->build(); + $this->inflector = (new InflectorFactory())->build(); } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getMigrations(): array { @@ -87,7 +91,7 @@ public function getMigrations(): array } /** - * {@inheritdoc} + * {@inheritDoc} */ public function registerMigration(string $name, string $class, string $body = null): string { diff --git a/src/Migration.php b/src/Migration.php index 98e040a..22f2615 100644 --- a/src/Migration.php +++ b/src/Migration.php @@ -17,6 +17,8 @@ use Cycle\Migrations\Migration\DefinitionInterface; use Cycle\Migrations\Migration\ProvidesSyncStateInterface; use Cycle\Migrations\Migration\State; +use Spiral\Migrations\Migration\State as SpiralState; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; /** * Simple migration class with shortcut for database and blueprint instances. @@ -41,9 +43,9 @@ public function getDatabase(): ?string } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function withCapsule(CapsuleInterface $capsule): DefinitionInterface + public function withCapsule(SpiralCapsuleInterface $capsule): DefinitionInterface { $migration = clone $this; $migration->capsule = $capsule; @@ -52,9 +54,9 @@ public function withCapsule(CapsuleInterface $capsule): DefinitionInterface } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function withState(State $state): ProvidesSyncStateInterface + public function withState(SpiralState $state): ProvidesSyncStateInterface { $migration = clone $this; $migration->state = $state; @@ -63,7 +65,7 @@ public function withState(State $state): ProvidesSyncStateInterface } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getState(): State { @@ -90,7 +92,6 @@ protected function database(): DatabaseInterface * Get table schema builder (blueprint). * * @param string $table - * * @return TableBlueprint */ protected function table(string $table): TableBlueprint diff --git a/src/Migration/DefinitionInterface.php b/src/Migration/DefinitionInterface.php index 4d905bb..d0ae41a 100644 --- a/src/Migration/DefinitionInterface.php +++ b/src/Migration/DefinitionInterface.php @@ -12,6 +12,7 @@ namespace Cycle\Migrations\Migration; use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\MigrationException; interface DefinitionInterface @@ -19,11 +20,12 @@ interface DefinitionInterface /** * Lock migration into specific migration capsule. * - * @param CapsuleInterface $capsule + * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument + * signature will be changed to {@see CapsuleInterface} in further release. * * @return self */ - public function withCapsule(CapsuleInterface $capsule): self; + public function withCapsule(SpiralCapsuleInterface $capsule): self; /** * Target migration database. Each migration must be specific to one diff --git a/src/Migration/ProvidesSyncStateInterface.php b/src/Migration/ProvidesSyncStateInterface.php index 212adeb..fba9a54 100644 --- a/src/Migration/ProvidesSyncStateInterface.php +++ b/src/Migration/ProvidesSyncStateInterface.php @@ -12,6 +12,7 @@ namespace Cycle\Migrations\Migration; use Cycle\Migrations\Exception\MigrationException; +use Spiral\Migrations\Migration\State as SpiralState; /** * An interface for migrations providing information about the migration status. @@ -21,11 +22,12 @@ interface ProvidesSyncStateInterface /** * Alter associated migration state (new migration instance to be created). * - * @param State $state + * @param SpiralState|State $state This argument signature will be changed + * to {@see State} in further release. * * @return static */ - public function withState(State $state): self; + public function withState(SpiralState $state): self; /** * Get migration state. diff --git a/src/Migrator.php b/src/Migrator.php index 7fba200..f61db1c 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -13,12 +13,16 @@ use Cycle\Database\Database; use Cycle\Database\DatabaseManager; +use Spiral\Database\DatabaseManager as SpiralDatabaseManager; use Cycle\Database\Table; use Cycle\Migrations\Config\MigrationConfig; +use Spiral\Migrations\Config\MigrationConfig as SpiralMigrationConfig; use Cycle\Migrations\Exception\MigrationException; use Cycle\Migrations\Migration\State; use Cycle\Migrations\Migration\Status; use Cycle\Migrations\Migrator\MigrationsTable; +use Spiral\Migrations\RepositoryInterface as SpiralRepositoryInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; final class Migrator implements MigratorInterface { @@ -34,14 +38,17 @@ final class Migrator implements MigratorInterface private $repository; /** - * @param MigrationConfig $config - * @param DatabaseManager $dbal - * @param RepositoryInterface $repository + * @param SpiralMigrationConfig|MigrationConfig $config This argument signature + * will be changed to {@see MigrationConfig} in further release. + * @param SpiralDatabaseManager|DatabaseManager $dbal This argument signature + * will be changed to {@see DatabaseManager} in further release. + * @param SpiralRepositoryInterface|RepositoryInterface $repository This argument + * signature will be changed to {@see RepositoryInterface} in further release. */ public function __construct( - MigrationConfig $config, - DatabaseManager $dbal, - RepositoryInterface $repository + SpiralMigrationConfig $config, + SpiralDatabaseManager $dbal, + SpiralRepositoryInterface $repository ) { $this->config = $config; $this->repository = $repository; @@ -134,9 +141,8 @@ private function createMigrationTable(Database $database): void /** * Get every available migration with valid meta information. * - * @throws \Exception - * * @return MigrationInterface[] + * @throws \Exception */ public function getMigrations(): array { @@ -153,7 +159,7 @@ public function getMigrations(): array /** * {@inheritDoc} */ - public function run(CapsuleInterface $capsule = null): ?MigrationInterface + public function run(SpiralCapsuleInterface $capsule = null): ?MigrationInterface { if (!$this->isConfigured()) { $this->configure(); @@ -205,13 +211,9 @@ static function () use ($migration, $capsule): void { } /** - * @param CapsuleInterface|null $capsule - * - * @throws \Throwable - * - * @return MigrationInterface|null + * {@inheritDoc} */ - public function rollback(CapsuleInterface $capsule = null): ?MigrationInterface + public function rollback(SpiralCapsuleInterface $capsule = null): ?MigrationInterface { if (!$this->isConfigured()) { $this->configure(); @@ -248,10 +250,8 @@ static function () use ($migration, $capsule): void { * Clarify migration state with valid status and execution time * * @param MigrationInterface $migration - * - * @throws \Exception - * * @return State + * @throws \Exception */ private function resolveState(MigrationInterface $migration): State { @@ -356,7 +356,6 @@ private function restoreMigrationData(): void * the issue {@link https://github.com/spiral/migrations/issues/13}. * * @param iterable $databases - * * @return bool */ private function isRestoreMigrationDataRequired(iterable $databases): bool @@ -381,7 +380,6 @@ private function isRestoreMigrationDataRequired(iterable $databases): bool * migration creation date. * * @param MigrationInterface $migration - * * @return \DateTimeInterface */ private function getMigrationCreatedAtForDb(MigrationInterface $migration): \DateTimeInterface diff --git a/src/Migrator/MigrationsTable.php b/src/Migrator/MigrationsTable.php index 1781af0..cf5d357 100644 --- a/src/Migrator/MigrationsTable.php +++ b/src/Migrator/MigrationsTable.php @@ -12,6 +12,7 @@ namespace Cycle\Migrations\Migrator; use Cycle\Database\Database; +use Spiral\Database\Database as SpiralDatabase; use Cycle\Database\Schema\AbstractTable; /** @@ -63,10 +64,11 @@ class MigrationsTable private $schema; /** - * @param Database $db + * @param SpiralDatabase|Database $db This argument signature will be + * changed to {@see Database} in further release. * @param string $name */ - public function __construct(Database $db, string $name) + public function __construct(SpiralDatabase $db, string $name) { $this->db = $db; $this->name = $name; diff --git a/src/MigratorInterface.php b/src/MigratorInterface.php index d361f65..1d85a29 100644 --- a/src/MigratorInterface.php +++ b/src/MigratorInterface.php @@ -11,6 +11,7 @@ namespace Cycle\Migrations; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\MigrationException; interface MigratorInterface @@ -23,22 +24,20 @@ public function configure(): void; /** * Execute one migration and return it's instance. * - * @param CapsuleInterface|null $capsule - * - * @throws MigrationException - * + * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule This argument + * signature will be changed to {@see CapsuleInterface} in further release. * @return MigrationInterface|null + * @throws MigrationException */ - public function run(CapsuleInterface $capsule = null): ?MigrationInterface; + public function run(SpiralCapsuleInterface $capsule = null): ?MigrationInterface; /** * Rollback last migration and return it's instance. * - * @param CapsuleInterface|null $capsule - * - * @throws MigrationException - * + * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule This argument + * signature will be changed to {@see CapsuleInterface} in further release. * @return MigrationInterface|null + * @throws MigrationException */ - public function rollback(CapsuleInterface $capsule = null): ?MigrationInterface; + public function rollback(SpiralCapsuleInterface $capsule = null): ?MigrationInterface; } diff --git a/src/Operation/AbstractOperation.php b/src/Operation/AbstractOperation.php index c3b8704..26d89c5 100644 --- a/src/Operation/AbstractOperation.php +++ b/src/Operation/AbstractOperation.php @@ -27,7 +27,7 @@ public function __construct(string $table) } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getTable(): string { diff --git a/src/Operation/Column/Add.php b/src/Operation/Column/Add.php index b49bce6..9547a3d 100644 --- a/src/Operation/Column/Add.php +++ b/src/Operation/Column/Add.php @@ -11,15 +11,15 @@ namespace Cycle\Migrations\Operation\Column; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ColumnException; final class Add extends Column { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Column/Alter.php b/src/Operation/Column/Alter.php index 30129a1..3fce5c9 100644 --- a/src/Operation/Column/Alter.php +++ b/src/Operation/Column/Alter.php @@ -11,15 +11,15 @@ namespace Cycle\Migrations\Operation\Column; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ColumnException; final class Alter extends Column { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Column/Column.php b/src/Operation/Column/Column.php index fb937f6..875d699 100644 --- a/src/Operation/Column/Column.php +++ b/src/Operation/Column/Column.php @@ -13,6 +13,7 @@ use Cycle\Database\Schema\AbstractColumn; use Cycle\Database\Schema\AbstractTable; +use Spiral\Database\Schema\AbstractTable as SpiralAbstractTable; use Cycle\Migrations\Exception\Operation\ColumnException; use Cycle\Migrations\Operation\AbstractOperation; use Cycle\Migrations\Operation\Traits\OptionsTrait; @@ -57,13 +58,12 @@ public function __construct( } /** - * @param AbstractTable $schema - * - * @throws ColumnException - * + * @param SpiralAbstractTable|AbstractTable $schema This argument signature + * will be changed to {@see AbstractTable} in further release. * @return AbstractColumn + * @throws \ReflectionException */ - protected function declareColumn(AbstractTable $schema): AbstractColumn + protected function declareColumn(SpiralAbstractTable $schema): AbstractColumn { $column = $schema->column($this->name); diff --git a/src/Operation/Column/Drop.php b/src/Operation/Column/Drop.php index 95abb6a..f8c9c0d 100644 --- a/src/Operation/Column/Drop.php +++ b/src/Operation/Column/Drop.php @@ -11,7 +11,7 @@ namespace Cycle\Migrations\Operation\Column; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ColumnException; use Cycle\Migrations\Operation\AbstractOperation; @@ -35,9 +35,9 @@ public function __construct(string $table, string $name) } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Column/Rename.php b/src/Operation/Column/Rename.php index f487dd2..77b78e5 100644 --- a/src/Operation/Column/Rename.php +++ b/src/Operation/Column/Rename.php @@ -11,7 +11,7 @@ namespace Cycle\Migrations\Operation\Column; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ColumnException; use Cycle\Migrations\Operation\AbstractOperation; @@ -36,9 +36,9 @@ public function __construct(string $table, string $name, string $newName) } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/ForeignKey/Add.php b/src/Operation/ForeignKey/Add.php index d006347..11a7eff 100644 --- a/src/Operation/ForeignKey/Add.php +++ b/src/Operation/ForeignKey/Add.php @@ -12,7 +12,7 @@ namespace Cycle\Migrations\Operation\ForeignKey; use Cycle\Database\ForeignKeyInterface; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ForeignKeyException; use Cycle\Migrations\Operation\Traits\OptionsTrait; @@ -49,9 +49,9 @@ public function __construct( } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/ForeignKey/Alter.php b/src/Operation/ForeignKey/Alter.php index d82adcf..33ab697 100644 --- a/src/Operation/ForeignKey/Alter.php +++ b/src/Operation/ForeignKey/Alter.php @@ -12,7 +12,7 @@ namespace Cycle\Migrations\Operation\ForeignKey; use Cycle\Database\ForeignKeyInterface; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ForeignKeyException; use Cycle\Migrations\Operation\Traits\OptionsTrait; @@ -47,9 +47,9 @@ public function __construct( } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/ForeignKey/Drop.php b/src/Operation/ForeignKey/Drop.php index e7d3690..cfe9b6a 100644 --- a/src/Operation/ForeignKey/Drop.php +++ b/src/Operation/ForeignKey/Drop.php @@ -11,15 +11,15 @@ namespace Cycle\Migrations\Operation\ForeignKey; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\ForeignKeyException; final class Drop extends ForeignKey { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Index/Add.php b/src/Operation/Index/Add.php index 7e426a9..2b302fa 100644 --- a/src/Operation/Index/Add.php +++ b/src/Operation/Index/Add.php @@ -11,7 +11,7 @@ namespace Cycle\Migrations\Operation\Index; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\IndexException; use Cycle\Migrations\Operation\Traits\OptionsTrait; @@ -31,9 +31,9 @@ public function __construct(string $table, array $columns, array $options = []) } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Index/Alter.php b/src/Operation/Index/Alter.php index 6800ba0..1710c79 100644 --- a/src/Operation/Index/Alter.php +++ b/src/Operation/Index/Alter.php @@ -11,7 +11,7 @@ namespace Cycle\Migrations\Operation\Index; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\IndexException; use Cycle\Migrations\Operation\Traits\OptionsTrait; @@ -31,9 +31,9 @@ public function __construct(string $table, array $columns, array $options = []) } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Index/Drop.php b/src/Operation/Index/Drop.php index a1bc7d0..90000be 100644 --- a/src/Operation/Index/Drop.php +++ b/src/Operation/Index/Drop.php @@ -11,15 +11,15 @@ namespace Cycle\Migrations\Operation\Index; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\IndexException; final class Drop extends Index { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); diff --git a/src/Operation/Table/Create.php b/src/Operation/Table/Create.php index 6d0155e..b055815 100644 --- a/src/Operation/Table/Create.php +++ b/src/Operation/Table/Create.php @@ -12,16 +12,16 @@ namespace Cycle\Migrations\Operation\Table; use Cycle\Database\Driver\HandlerInterface; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\TableException; use Cycle\Migrations\Operation\AbstractOperation; final class Create extends AbstractOperation { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); $database = $this->database ?? '[default]'; diff --git a/src/Operation/Table/Drop.php b/src/Operation/Table/Drop.php index d65bbbd..276208c 100644 --- a/src/Operation/Table/Drop.php +++ b/src/Operation/Table/Drop.php @@ -12,16 +12,16 @@ namespace Cycle\Migrations\Operation\Table; use Cycle\Database\Driver\HandlerInterface; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\TableException; use Cycle\Migrations\Operation\AbstractOperation; final class Drop extends AbstractOperation { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); $database = $this->database ?? '[default]'; diff --git a/src/Operation/Table/PrimaryKeys.php b/src/Operation/Table/PrimaryKeys.php index 5a0538f..34b4324 100644 --- a/src/Operation/Table/PrimaryKeys.php +++ b/src/Operation/Table/PrimaryKeys.php @@ -11,7 +11,7 @@ namespace Cycle\Migrations\Operation\Table; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\TableException; use Cycle\Migrations\Operation\AbstractOperation; @@ -31,9 +31,9 @@ public function __construct(string $table, array $columns) } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); $database = $this->database ?? '[default]'; diff --git a/src/Operation/Table/Rename.php b/src/Operation/Table/Rename.php index f2b11ae..cc392e6 100644 --- a/src/Operation/Table/Rename.php +++ b/src/Operation/Table/Rename.php @@ -12,7 +12,7 @@ namespace Cycle\Migrations\Operation\Table; use Cycle\Database\Driver\HandlerInterface; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\TableException; use Cycle\Migrations\Operation\AbstractOperation; @@ -32,9 +32,9 @@ public function __construct(string $table, string $newName) } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); $database = $this->database ?? '[default]'; diff --git a/src/Operation/Table/Update.php b/src/Operation/Table/Update.php index af60150..2207cd5 100644 --- a/src/Operation/Table/Update.php +++ b/src/Operation/Table/Update.php @@ -12,16 +12,16 @@ namespace Cycle\Migrations\Operation\Table; use Cycle\Database\Driver\HandlerInterface; -use Cycle\Migrations\CapsuleInterface; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; use Cycle\Migrations\Exception\Operation\TableException; use Cycle\Migrations\Operation\AbstractOperation; final class Update extends AbstractOperation { /** - * {@inheritdoc} + * {@inheritDoc} */ - public function execute(CapsuleInterface $capsule): void + public function execute(SpiralCapsuleInterface $capsule): void { $schema = $capsule->getSchema($this->getTable()); $database = $this->database ?? '[default]'; diff --git a/src/OperationInterface.php b/src/OperationInterface.php index 9e49450..db676de 100644 --- a/src/OperationInterface.php +++ b/src/OperationInterface.php @@ -12,6 +12,7 @@ namespace Cycle\Migrations; use Cycle\Migrations\Exception\OperationException; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; /** * Represents simple table operation. Operation is a bridge between command and declarative @@ -29,9 +30,9 @@ public function getTable(): string; /** * Execute operation in a given capsule. * - * @param CapsuleInterface $capsule - * + * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument + * signature will be changed to {@see CapsuleInterface} in further release. * @throws OperationException */ - public function execute(CapsuleInterface $capsule); + public function execute(SpiralCapsuleInterface $capsule); } diff --git a/src/RepositoryInterface.php b/src/RepositoryInterface.php index ef076bb..340697f 100644 --- a/src/RepositoryInterface.php +++ b/src/RepositoryInterface.php @@ -21,9 +21,8 @@ interface RepositoryInterface * * Attention, Capsule must be set for migration before executing it. * - * @throws RepositoryException - * * @return MigrationInterface[] + * @throws RepositoryException */ public function getMigrations(): array; @@ -33,7 +32,7 @@ public function getMigrations(): array; * * @param string $name * @param string $class - * @param string $body When body is null repository will try to copy content from a specific + * @param string|null $body When body is null repository will try to copy content from a specific * class filename. Must include all PHP headers. * * @throws RepositoryException diff --git a/src/TableBlueprint.php b/src/TableBlueprint.php index 10f9d49..d9685bf 100644 --- a/src/TableBlueprint.php +++ b/src/TableBlueprint.php @@ -13,6 +13,8 @@ use Cycle\Database\Schema\AbstractTable; use Cycle\Migrations\Exception\BlueprintException; +use Spiral\Migrations\CapsuleInterface as SpiralCapsuleInterface; +use Spiral\Migrations\OperationInterface as SpiralOperationInterface; /** * TableBlueprint is abstraction wrapper at top of AbstractTable which converts command based @@ -33,10 +35,11 @@ final class TableBlueprint private $table = ''; /** - * @param CapsuleInterface $capsule - * @param string $table + * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument + * signature will be changed to {@see CapsuleInterface} in further release. + * @param string $table */ - public function __construct(CapsuleInterface $capsule, string $table) + public function __construct(SpiralCapsuleInterface $capsule, string $table) { $this->capsule = $capsule; $this->table = $table; @@ -305,11 +308,11 @@ public function rename(string $newName): void /** * Register new operation. * - * @param OperationInterface $operation - * + * @param SpiralOperationInterface|OperationInterface $operation This argument + * signature will be changed to {@see OperationInterface} in further release. * @return TableBlueprint */ - public function addOperation(OperationInterface $operation): self + public function addOperation(SpiralOperationInterface $operation): self { $this->operations[] = $operation; From fa1619af9ab84b59785ff9b07542e68f509070ad Mon Sep 17 00:00:00 2001 From: Kirill Nesmeyanov Date: Tue, 12 Oct 2021 10:00:36 +0000 Subject: [PATCH 2/5] Apply fixes from StyleCI --- src/Atomizer/Atomizer.php | 5 +++-- src/Atomizer/Renderer.php | 14 +++++++++++--- src/Atomizer/RendererInterface.php | 6 +++--- src/Capsule.php | 2 +- src/FileRepository.php | 2 +- src/Migration.php | 1 + src/Migration/DefinitionInterface.php | 2 +- src/Migrator.php | 15 ++++++++++----- src/Migrator/MigrationsTable.php | 2 +- src/MigratorInterface.php | 12 ++++++++---- src/Operation/Column/Column.php | 6 ++++-- src/OperationInterface.php | 3 ++- src/RepositoryInterface.php | 3 ++- src/TableBlueprint.php | 5 +++-- 14 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/Atomizer/Atomizer.php b/src/Atomizer/Atomizer.php index c1377f4..d80df04 100644 --- a/src/Atomizer/Atomizer.php +++ b/src/Atomizer/Atomizer.php @@ -30,7 +30,7 @@ final class Atomizer private $renderer; /** - * @param SpiralRendererInterface|RendererInterface $renderer This argument + * @param RendererInterface|SpiralRendererInterface $renderer This argument * signature will be changed to {@see RendererInterface} in further release. */ public function __construct(SpiralRendererInterface $renderer) @@ -41,8 +41,9 @@ public function __construct(SpiralRendererInterface $renderer) /** * Add new table into atomizer. * - * @param SpiralAbstractTable|AbstractTable $table This argument signature + * @param AbstractTable|SpiralAbstractTable $table This argument signature * will be changed to {@see AbstractTable} in further release. + * * @return Atomizer */ public function addTable(SpiralAbstractTable $table): self diff --git a/src/Atomizer/Renderer.php b/src/Atomizer/Renderer.php index be0de80..848e25e 100644 --- a/src/Atomizer/Renderer.php +++ b/src/Atomizer/Renderer.php @@ -368,6 +368,7 @@ protected function alterColumn( * @param Source $source * @param string $format * @param array ...$values + * * @throws \ReflectionException */ protected function render(Source $source, string $format, ...$values): void @@ -416,8 +417,10 @@ protected function render(Source $source, string $format, ...$values): void /** * @param Serializer $serializer * @param AbstractColumn $column - * @return string + * * @throws \ReflectionException + * + * @return string */ private function columnOptions(Serializer $serializer, AbstractColumn $column): string { @@ -445,8 +448,10 @@ private function columnOptions(Serializer $serializer, AbstractColumn $column): /** * @param Serializer $serializer * @param AbstractIndex $index - * @return string + * * @throws \ReflectionException + * + * @return string */ private function indexOptions(Serializer $serializer, AbstractIndex $index): string { @@ -463,8 +468,10 @@ private function indexOptions(Serializer $serializer, AbstractIndex $index): str /** * @param Serializer $serializer * @param AbstractForeignKey $reference - * @return string + * * @throws \ReflectionException + * + * @return string */ private function foreignKeyOptions(Serializer $serializer, AbstractForeignKey $reference): string { @@ -483,6 +490,7 @@ private function foreignKeyOptions(Serializer $serializer, AbstractForeignKey $r * Mount indents for column and index options. * * @param string $serialized + * * @return string */ private function mountIndents(string $serialized): string diff --git a/src/Atomizer/RendererInterface.php b/src/Atomizer/RendererInterface.php index fb24bdc..916c6bd 100644 --- a/src/Atomizer/RendererInterface.php +++ b/src/Atomizer/RendererInterface.php @@ -24,7 +24,7 @@ interface RendererInterface * Migration engine specific table creation syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table This argument signature + * @param AbstractTable|SpiralAbstractTable $table This argument signature * will be changed to {@see AbstractTable} in further release. */ public function createTable(Source $source, SpiralAbstractTable $table); @@ -33,7 +33,7 @@ public function createTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table update syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table This argument signature + * @param AbstractTable|SpiralAbstractTable $table This argument signature * will be changed to {@see AbstractTable} in further release. */ public function updateTable(Source $source, SpiralAbstractTable $table); @@ -42,7 +42,7 @@ public function updateTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table revert syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table This argument signature + * @param AbstractTable|SpiralAbstractTable $table This argument signature * will be changed to {@see AbstractTable} in further release. */ public function revertTable(Source $source, SpiralAbstractTable $table); diff --git a/src/Capsule.php b/src/Capsule.php index b1dfac5..fc6a700 100644 --- a/src/Capsule.php +++ b/src/Capsule.php @@ -31,7 +31,7 @@ final class Capsule implements CapsuleInterface private $schemas = []; /** - * @param SpiralDatabase|Database $database This argument signature will be + * @param Database|SpiralDatabase $database This argument signature will be * changed to {@see Database} in further release. */ public function __construct(SpiralDatabase $database) diff --git a/src/FileRepository.php b/src/FileRepository.php index 2fd69e9..ff251ce 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -50,7 +50,7 @@ final class FileRepository implements RepositoryInterface private $inflector; /** - * @param SpiralMigrationConfig|MigrationConfig $config This argument + * @param MigrationConfig|SpiralMigrationConfig $config This argument * signature will be changed to {@see MigrationConfig} in further release. * @param FactoryInterface|null $factory */ diff --git a/src/Migration.php b/src/Migration.php index 22f2615..e560376 100644 --- a/src/Migration.php +++ b/src/Migration.php @@ -92,6 +92,7 @@ protected function database(): DatabaseInterface * Get table schema builder (blueprint). * * @param string $table + * * @return TableBlueprint */ protected function table(string $table): TableBlueprint diff --git a/src/Migration/DefinitionInterface.php b/src/Migration/DefinitionInterface.php index d0ae41a..3e5aabf 100644 --- a/src/Migration/DefinitionInterface.php +++ b/src/Migration/DefinitionInterface.php @@ -20,7 +20,7 @@ interface DefinitionInterface /** * Lock migration into specific migration capsule. * - * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument + * @param CapsuleInterface|SpiralCapsuleInterface $capsule This argument * signature will be changed to {@see CapsuleInterface} in further release. * * @return self diff --git a/src/Migrator.php b/src/Migrator.php index f61db1c..4649839 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -38,11 +38,11 @@ final class Migrator implements MigratorInterface private $repository; /** - * @param SpiralMigrationConfig|MigrationConfig $config This argument signature + * @param MigrationConfig|SpiralMigrationConfig $config This argument signature * will be changed to {@see MigrationConfig} in further release. - * @param SpiralDatabaseManager|DatabaseManager $dbal This argument signature + * @param DatabaseManager|SpiralDatabaseManager $dbal This argument signature * will be changed to {@see DatabaseManager} in further release. - * @param SpiralRepositoryInterface|RepositoryInterface $repository This argument + * @param RepositoryInterface|SpiralRepositoryInterface $repository This argument * signature will be changed to {@see RepositoryInterface} in further release. */ public function __construct( @@ -141,8 +141,9 @@ private function createMigrationTable(Database $database): void /** * Get every available migration with valid meta information. * - * @return MigrationInterface[] * @throws \Exception + * + * @return MigrationInterface[] */ public function getMigrations(): array { @@ -250,8 +251,10 @@ static function () use ($migration, $capsule): void { * Clarify migration state with valid status and execution time * * @param MigrationInterface $migration - * @return State + * * @throws \Exception + * + * @return State */ private function resolveState(MigrationInterface $migration): State { @@ -356,6 +359,7 @@ private function restoreMigrationData(): void * the issue {@link https://github.com/spiral/migrations/issues/13}. * * @param iterable $databases + * * @return bool */ private function isRestoreMigrationDataRequired(iterable $databases): bool @@ -380,6 +384,7 @@ private function isRestoreMigrationDataRequired(iterable $databases): bool * migration creation date. * * @param MigrationInterface $migration + * * @return \DateTimeInterface */ private function getMigrationCreatedAtForDb(MigrationInterface $migration): \DateTimeInterface diff --git a/src/Migrator/MigrationsTable.php b/src/Migrator/MigrationsTable.php index cf5d357..069b3b1 100644 --- a/src/Migrator/MigrationsTable.php +++ b/src/Migrator/MigrationsTable.php @@ -64,7 +64,7 @@ class MigrationsTable private $schema; /** - * @param SpiralDatabase|Database $db This argument signature will be + * @param Database|SpiralDatabase $db This argument signature will be * changed to {@see Database} in further release. * @param string $name */ diff --git a/src/MigratorInterface.php b/src/MigratorInterface.php index 1d85a29..cd4e0e5 100644 --- a/src/MigratorInterface.php +++ b/src/MigratorInterface.php @@ -24,20 +24,24 @@ public function configure(): void; /** * Execute one migration and return it's instance. * - * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule This argument + * @param CapsuleInterface|SpiralCapsuleInterface|null $capsule This argument * signature will be changed to {@see CapsuleInterface} in further release. - * @return MigrationInterface|null + * * @throws MigrationException + * + * @return MigrationInterface|null */ public function run(SpiralCapsuleInterface $capsule = null): ?MigrationInterface; /** * Rollback last migration and return it's instance. * - * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule This argument + * @param CapsuleInterface|SpiralCapsuleInterface|null $capsule This argument * signature will be changed to {@see CapsuleInterface} in further release. - * @return MigrationInterface|null + * * @throws MigrationException + * + * @return MigrationInterface|null */ public function rollback(SpiralCapsuleInterface $capsule = null): ?MigrationInterface; } diff --git a/src/Operation/Column/Column.php b/src/Operation/Column/Column.php index 875d699..ee22742 100644 --- a/src/Operation/Column/Column.php +++ b/src/Operation/Column/Column.php @@ -58,10 +58,12 @@ public function __construct( } /** - * @param SpiralAbstractTable|AbstractTable $schema This argument signature + * @param AbstractTable|SpiralAbstractTable $schema This argument signature * will be changed to {@see AbstractTable} in further release. - * @return AbstractColumn + * * @throws \ReflectionException + * + * @return AbstractColumn */ protected function declareColumn(SpiralAbstractTable $schema): AbstractColumn { diff --git a/src/OperationInterface.php b/src/OperationInterface.php index db676de..207ceb4 100644 --- a/src/OperationInterface.php +++ b/src/OperationInterface.php @@ -30,8 +30,9 @@ public function getTable(): string; /** * Execute operation in a given capsule. * - * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument + * @param CapsuleInterface|SpiralCapsuleInterface $capsule This argument * signature will be changed to {@see CapsuleInterface} in further release. + * * @throws OperationException */ public function execute(SpiralCapsuleInterface $capsule); diff --git a/src/RepositoryInterface.php b/src/RepositoryInterface.php index 340697f..c07624a 100644 --- a/src/RepositoryInterface.php +++ b/src/RepositoryInterface.php @@ -21,8 +21,9 @@ interface RepositoryInterface * * Attention, Capsule must be set for migration before executing it. * - * @return MigrationInterface[] * @throws RepositoryException + * + * @return MigrationInterface[] */ public function getMigrations(): array; diff --git a/src/TableBlueprint.php b/src/TableBlueprint.php index d9685bf..2e44e7a 100644 --- a/src/TableBlueprint.php +++ b/src/TableBlueprint.php @@ -35,7 +35,7 @@ final class TableBlueprint private $table = ''; /** - * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument + * @param CapsuleInterface|SpiralCapsuleInterface $capsule This argument * signature will be changed to {@see CapsuleInterface} in further release. * @param string $table */ @@ -308,8 +308,9 @@ public function rename(string $newName): void /** * Register new operation. * - * @param SpiralOperationInterface|OperationInterface $operation This argument + * @param OperationInterface|SpiralOperationInterface $operation This argument * signature will be changed to {@see OperationInterface} in further release. + * * @return TableBlueprint */ public function addOperation(SpiralOperationInterface $operation): self From 5822dba0edc0abb9ea073e193a7fb4d061e0f2a4 Mon Sep 17 00:00:00 2001 From: SerafimArts Date: Tue, 12 Oct 2021 14:26:40 +0300 Subject: [PATCH 3/5] Description typo --- src/Atomizer/Atomizer.php | 8 ++++---- src/Atomizer/RendererInterface.php | 16 ++++++++-------- src/Capsule.php | 4 ++-- src/FileRepository.php | 4 ++-- src/Migration/DefinitionInterface.php | 4 ++-- src/Migration/ProvidesSyncStateInterface.php | 4 ++-- src/Migrator.php | 12 ++++++------ src/Migrator/MigrationsTable.php | 4 ++-- src/MigratorInterface.php | 8 ++++---- src/Operation/Column/Column.php | 4 ++-- src/OperationInterface.php | 4 ++-- src/TableBlueprint.php | 8 ++++---- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Atomizer/Atomizer.php b/src/Atomizer/Atomizer.php index c1377f4..d88011c 100644 --- a/src/Atomizer/Atomizer.php +++ b/src/Atomizer/Atomizer.php @@ -30,8 +30,8 @@ final class Atomizer private $renderer; /** - * @param SpiralRendererInterface|RendererInterface $renderer This argument - * signature will be changed to {@see RendererInterface} in further release. + * @param SpiralRendererInterface|RendererInterface $renderer The signature of this + * argument will be changed to {@see RendererInterface} in future release. */ public function __construct(SpiralRendererInterface $renderer) { @@ -41,8 +41,8 @@ public function __construct(SpiralRendererInterface $renderer) /** * Add new table into atomizer. * - * @param SpiralAbstractTable|AbstractTable $table This argument signature - * will be changed to {@see AbstractTable} in further release. + * @param SpiralAbstractTable|AbstractTable $table The signature of this + * argument will be changed to {@see AbstractTable} in future release. * @return Atomizer */ public function addTable(SpiralAbstractTable $table): self diff --git a/src/Atomizer/RendererInterface.php b/src/Atomizer/RendererInterface.php index fb24bdc..3705ebb 100644 --- a/src/Atomizer/RendererInterface.php +++ b/src/Atomizer/RendererInterface.php @@ -24,8 +24,8 @@ interface RendererInterface * Migration engine specific table creation syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table This argument signature - * will be changed to {@see AbstractTable} in further release. + * @param SpiralAbstractTable|AbstractTable $table The signature of this + * argument will be changed to {@see AbstractTable} in future release. */ public function createTable(Source $source, SpiralAbstractTable $table); @@ -33,8 +33,8 @@ public function createTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table update syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table This argument signature - * will be changed to {@see AbstractTable} in further release. + * @param SpiralAbstractTable|AbstractTable $table The signature of this + * argument will be changed to {@see AbstractTable} in future release. */ public function updateTable(Source $source, SpiralAbstractTable $table); @@ -42,8 +42,8 @@ public function updateTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table revert syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table This argument signature - * will be changed to {@see AbstractTable} in further release. + * @param SpiralAbstractTable|AbstractTable $table The signature of this + * argument will be changed to {@see AbstractTable} in future release. */ public function revertTable(Source $source, SpiralAbstractTable $table); @@ -51,8 +51,8 @@ public function revertTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table drop syntax. * * @param Source $source - * @param SpiralAbstractTable $table This argument signature will be changed - * to {@see AbstractTable} in further release. + * @param SpiralAbstractTable|AbstractTable $table The signature of this + * argument will be changed to {@see AbstractTable} in future release. */ public function dropTable(Source $source, SpiralAbstractTable $table); } diff --git a/src/Capsule.php b/src/Capsule.php index b1dfac5..844e9cb 100644 --- a/src/Capsule.php +++ b/src/Capsule.php @@ -31,8 +31,8 @@ final class Capsule implements CapsuleInterface private $schemas = []; /** - * @param SpiralDatabase|Database $database This argument signature will be - * changed to {@see Database} in further release. + * @param SpiralDatabase|Database $database The signature of this argument + * will be changed to {@see Database} in future release. */ public function __construct(SpiralDatabase $database) { diff --git a/src/FileRepository.php b/src/FileRepository.php index 2fd69e9..f34b551 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -50,8 +50,8 @@ final class FileRepository implements RepositoryInterface private $inflector; /** - * @param SpiralMigrationConfig|MigrationConfig $config This argument - * signature will be changed to {@see MigrationConfig} in further release. + * @param SpiralMigrationConfig|MigrationConfig $config The signature of this + * argument will be changed to {@see MigrationConfig} in future release. * @param FactoryInterface|null $factory */ public function __construct(SpiralMigrationConfig $config, FactoryInterface $factory = null) diff --git a/src/Migration/DefinitionInterface.php b/src/Migration/DefinitionInterface.php index d0ae41a..351d753 100644 --- a/src/Migration/DefinitionInterface.php +++ b/src/Migration/DefinitionInterface.php @@ -20,8 +20,8 @@ interface DefinitionInterface /** * Lock migration into specific migration capsule. * - * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument - * signature will be changed to {@see CapsuleInterface} in further release. + * @param SpiralCapsuleInterface|CapsuleInterface $capsule The signature of this + * argument will be changed to {@see CapsuleInterface} in future release. * * @return self */ diff --git a/src/Migration/ProvidesSyncStateInterface.php b/src/Migration/ProvidesSyncStateInterface.php index fba9a54..82022d1 100644 --- a/src/Migration/ProvidesSyncStateInterface.php +++ b/src/Migration/ProvidesSyncStateInterface.php @@ -22,8 +22,8 @@ interface ProvidesSyncStateInterface /** * Alter associated migration state (new migration instance to be created). * - * @param SpiralState|State $state This argument signature will be changed - * to {@see State} in further release. + * @param SpiralState|State $state The signature of this argument will be + * changed to {@see State} in future release. * * @return static */ diff --git a/src/Migrator.php b/src/Migrator.php index f61db1c..3bbf2ad 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -38,12 +38,12 @@ final class Migrator implements MigratorInterface private $repository; /** - * @param SpiralMigrationConfig|MigrationConfig $config This argument signature - * will be changed to {@see MigrationConfig} in further release. - * @param SpiralDatabaseManager|DatabaseManager $dbal This argument signature - * will be changed to {@see DatabaseManager} in further release. - * @param SpiralRepositoryInterface|RepositoryInterface $repository This argument - * signature will be changed to {@see RepositoryInterface} in further release. + * @param SpiralMigrationConfig|MigrationConfig $config The signature of this + * argument will be changed to {@see MigrationConfig} in future release. + * @param SpiralDatabaseManager|DatabaseManager $dbal The signature of this + * argument will be changed to {@see DatabaseManager} in future release. + * @param SpiralRepositoryInterface|RepositoryInterface $repository The signature + * of this argument will be changed to {@see RepositoryInterface} in future release. */ public function __construct( SpiralMigrationConfig $config, diff --git a/src/Migrator/MigrationsTable.php b/src/Migrator/MigrationsTable.php index cf5d357..99cb4c3 100644 --- a/src/Migrator/MigrationsTable.php +++ b/src/Migrator/MigrationsTable.php @@ -64,8 +64,8 @@ class MigrationsTable private $schema; /** - * @param SpiralDatabase|Database $db This argument signature will be - * changed to {@see Database} in further release. + * @param SpiralDatabase|Database $db The signature of this argument will be + * changed to {@see Database} in future release. * @param string $name */ public function __construct(SpiralDatabase $db, string $name) diff --git a/src/MigratorInterface.php b/src/MigratorInterface.php index 1d85a29..37a5ef2 100644 --- a/src/MigratorInterface.php +++ b/src/MigratorInterface.php @@ -24,8 +24,8 @@ public function configure(): void; /** * Execute one migration and return it's instance. * - * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule This argument - * signature will be changed to {@see CapsuleInterface} in further release. + * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule The signature + * of this argument will be changed to {@see CapsuleInterface} in future release. * @return MigrationInterface|null * @throws MigrationException */ @@ -34,8 +34,8 @@ public function run(SpiralCapsuleInterface $capsule = null): ?MigrationInterface /** * Rollback last migration and return it's instance. * - * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule This argument - * signature will be changed to {@see CapsuleInterface} in further release. + * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule The signature + * of this argument will be changed to {@see CapsuleInterface} in future release. * @return MigrationInterface|null * @throws MigrationException */ diff --git a/src/Operation/Column/Column.php b/src/Operation/Column/Column.php index 875d699..5d17338 100644 --- a/src/Operation/Column/Column.php +++ b/src/Operation/Column/Column.php @@ -58,8 +58,8 @@ public function __construct( } /** - * @param SpiralAbstractTable|AbstractTable $schema This argument signature - * will be changed to {@see AbstractTable} in further release. + * @param SpiralAbstractTable|AbstractTable $schema The signature of this + * argument will be changed to {@see AbstractTable} in future release. * @return AbstractColumn * @throws \ReflectionException */ diff --git a/src/OperationInterface.php b/src/OperationInterface.php index db676de..b79d2f0 100644 --- a/src/OperationInterface.php +++ b/src/OperationInterface.php @@ -30,8 +30,8 @@ public function getTable(): string; /** * Execute operation in a given capsule. * - * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument - * signature will be changed to {@see CapsuleInterface} in further release. + * @param SpiralCapsuleInterface|CapsuleInterface $capsule The signature of this + * argument will be changed to {@see CapsuleInterface} in future release. * @throws OperationException */ public function execute(SpiralCapsuleInterface $capsule); diff --git a/src/TableBlueprint.php b/src/TableBlueprint.php index d9685bf..31be2af 100644 --- a/src/TableBlueprint.php +++ b/src/TableBlueprint.php @@ -35,8 +35,8 @@ final class TableBlueprint private $table = ''; /** - * @param SpiralCapsuleInterface|CapsuleInterface $capsule This argument - * signature will be changed to {@see CapsuleInterface} in further release. + * @param SpiralCapsuleInterface|CapsuleInterface $capsule The signature of this + * argument will be changed to {@see CapsuleInterface} in future release. * @param string $table */ public function __construct(SpiralCapsuleInterface $capsule, string $table) @@ -308,8 +308,8 @@ public function rename(string $newName): void /** * Register new operation. * - * @param SpiralOperationInterface|OperationInterface $operation This argument - * signature will be changed to {@see OperationInterface} in further release. + * @param SpiralOperationInterface|OperationInterface $operation The signature + * of this argument will be changed to {@see OperationInterface} in future release. * @return TableBlueprint */ public function addOperation(SpiralOperationInterface $operation): self From 29cb424c3a5c5c6a27e889dc3f84fcf06955b15d Mon Sep 17 00:00:00 2001 From: Kirill Nesmeyanov Date: Tue, 12 Oct 2021 11:30:31 +0000 Subject: [PATCH 4/5] Apply fixes from StyleCI --- src/Atomizer/Atomizer.php | 5 +++-- src/Atomizer/RendererInterface.php | 8 ++++---- src/Capsule.php | 2 +- src/FileRepository.php | 2 +- src/Migration/DefinitionInterface.php | 2 +- src/Migrator.php | 15 ++++++++++----- src/Migrator/MigrationsTable.php | 2 +- src/MigratorInterface.php | 12 ++++++++---- src/Operation/Column/Column.php | 6 ++++-- src/OperationInterface.php | 3 ++- src/TableBlueprint.php | 5 +++-- 11 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/Atomizer/Atomizer.php b/src/Atomizer/Atomizer.php index d88011c..e7d1c78 100644 --- a/src/Atomizer/Atomizer.php +++ b/src/Atomizer/Atomizer.php @@ -30,7 +30,7 @@ final class Atomizer private $renderer; /** - * @param SpiralRendererInterface|RendererInterface $renderer The signature of this + * @param RendererInterface|SpiralRendererInterface $renderer The signature of this * argument will be changed to {@see RendererInterface} in future release. */ public function __construct(SpiralRendererInterface $renderer) @@ -41,8 +41,9 @@ public function __construct(SpiralRendererInterface $renderer) /** * Add new table into atomizer. * - * @param SpiralAbstractTable|AbstractTable $table The signature of this + * @param AbstractTable|SpiralAbstractTable $table The signature of this * argument will be changed to {@see AbstractTable} in future release. + * * @return Atomizer */ public function addTable(SpiralAbstractTable $table): self diff --git a/src/Atomizer/RendererInterface.php b/src/Atomizer/RendererInterface.php index 3705ebb..828b9fa 100644 --- a/src/Atomizer/RendererInterface.php +++ b/src/Atomizer/RendererInterface.php @@ -24,7 +24,7 @@ interface RendererInterface * Migration engine specific table creation syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table The signature of this + * @param AbstractTable|SpiralAbstractTable $table The signature of this * argument will be changed to {@see AbstractTable} in future release. */ public function createTable(Source $source, SpiralAbstractTable $table); @@ -33,7 +33,7 @@ public function createTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table update syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table The signature of this + * @param AbstractTable|SpiralAbstractTable $table The signature of this * argument will be changed to {@see AbstractTable} in future release. */ public function updateTable(Source $source, SpiralAbstractTable $table); @@ -42,7 +42,7 @@ public function updateTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table revert syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table The signature of this + * @param AbstractTable|SpiralAbstractTable $table The signature of this * argument will be changed to {@see AbstractTable} in future release. */ public function revertTable(Source $source, SpiralAbstractTable $table); @@ -51,7 +51,7 @@ public function revertTable(Source $source, SpiralAbstractTable $table); * Migration engine specific table drop syntax. * * @param Source $source - * @param SpiralAbstractTable|AbstractTable $table The signature of this + * @param AbstractTable|SpiralAbstractTable $table The signature of this * argument will be changed to {@see AbstractTable} in future release. */ public function dropTable(Source $source, SpiralAbstractTable $table); diff --git a/src/Capsule.php b/src/Capsule.php index 844e9cb..2b9f779 100644 --- a/src/Capsule.php +++ b/src/Capsule.php @@ -31,7 +31,7 @@ final class Capsule implements CapsuleInterface private $schemas = []; /** - * @param SpiralDatabase|Database $database The signature of this argument + * @param Database|SpiralDatabase $database The signature of this argument * will be changed to {@see Database} in future release. */ public function __construct(SpiralDatabase $database) diff --git a/src/FileRepository.php b/src/FileRepository.php index f34b551..6b487bb 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -50,7 +50,7 @@ final class FileRepository implements RepositoryInterface private $inflector; /** - * @param SpiralMigrationConfig|MigrationConfig $config The signature of this + * @param MigrationConfig|SpiralMigrationConfig $config The signature of this * argument will be changed to {@see MigrationConfig} in future release. * @param FactoryInterface|null $factory */ diff --git a/src/Migration/DefinitionInterface.php b/src/Migration/DefinitionInterface.php index 351d753..5650454 100644 --- a/src/Migration/DefinitionInterface.php +++ b/src/Migration/DefinitionInterface.php @@ -20,7 +20,7 @@ interface DefinitionInterface /** * Lock migration into specific migration capsule. * - * @param SpiralCapsuleInterface|CapsuleInterface $capsule The signature of this + * @param CapsuleInterface|SpiralCapsuleInterface $capsule The signature of this * argument will be changed to {@see CapsuleInterface} in future release. * * @return self diff --git a/src/Migrator.php b/src/Migrator.php index 3bbf2ad..f1db51b 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -38,11 +38,11 @@ final class Migrator implements MigratorInterface private $repository; /** - * @param SpiralMigrationConfig|MigrationConfig $config The signature of this + * @param MigrationConfig|SpiralMigrationConfig $config The signature of this * argument will be changed to {@see MigrationConfig} in future release. - * @param SpiralDatabaseManager|DatabaseManager $dbal The signature of this + * @param DatabaseManager|SpiralDatabaseManager $dbal The signature of this * argument will be changed to {@see DatabaseManager} in future release. - * @param SpiralRepositoryInterface|RepositoryInterface $repository The signature + * @param RepositoryInterface|SpiralRepositoryInterface $repository The signature * of this argument will be changed to {@see RepositoryInterface} in future release. */ public function __construct( @@ -141,8 +141,9 @@ private function createMigrationTable(Database $database): void /** * Get every available migration with valid meta information. * - * @return MigrationInterface[] * @throws \Exception + * + * @return MigrationInterface[] */ public function getMigrations(): array { @@ -250,8 +251,10 @@ static function () use ($migration, $capsule): void { * Clarify migration state with valid status and execution time * * @param MigrationInterface $migration - * @return State + * * @throws \Exception + * + * @return State */ private function resolveState(MigrationInterface $migration): State { @@ -356,6 +359,7 @@ private function restoreMigrationData(): void * the issue {@link https://github.com/spiral/migrations/issues/13}. * * @param iterable $databases + * * @return bool */ private function isRestoreMigrationDataRequired(iterable $databases): bool @@ -380,6 +384,7 @@ private function isRestoreMigrationDataRequired(iterable $databases): bool * migration creation date. * * @param MigrationInterface $migration + * * @return \DateTimeInterface */ private function getMigrationCreatedAtForDb(MigrationInterface $migration): \DateTimeInterface diff --git a/src/Migrator/MigrationsTable.php b/src/Migrator/MigrationsTable.php index 99cb4c3..befafaa 100644 --- a/src/Migrator/MigrationsTable.php +++ b/src/Migrator/MigrationsTable.php @@ -64,7 +64,7 @@ class MigrationsTable private $schema; /** - * @param SpiralDatabase|Database $db The signature of this argument will be + * @param Database|SpiralDatabase $db The signature of this argument will be * changed to {@see Database} in future release. * @param string $name */ diff --git a/src/MigratorInterface.php b/src/MigratorInterface.php index 37a5ef2..129ecc4 100644 --- a/src/MigratorInterface.php +++ b/src/MigratorInterface.php @@ -24,20 +24,24 @@ public function configure(): void; /** * Execute one migration and return it's instance. * - * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule The signature + * @param CapsuleInterface|SpiralCapsuleInterface|null $capsule The signature * of this argument will be changed to {@see CapsuleInterface} in future release. - * @return MigrationInterface|null + * * @throws MigrationException + * + * @return MigrationInterface|null */ public function run(SpiralCapsuleInterface $capsule = null): ?MigrationInterface; /** * Rollback last migration and return it's instance. * - * @param SpiralCapsuleInterface|CapsuleInterface|null $capsule The signature + * @param CapsuleInterface|SpiralCapsuleInterface|null $capsule The signature * of this argument will be changed to {@see CapsuleInterface} in future release. - * @return MigrationInterface|null + * * @throws MigrationException + * + * @return MigrationInterface|null */ public function rollback(SpiralCapsuleInterface $capsule = null): ?MigrationInterface; } diff --git a/src/Operation/Column/Column.php b/src/Operation/Column/Column.php index 5d17338..1242bab 100644 --- a/src/Operation/Column/Column.php +++ b/src/Operation/Column/Column.php @@ -58,10 +58,12 @@ public function __construct( } /** - * @param SpiralAbstractTable|AbstractTable $schema The signature of this + * @param AbstractTable|SpiralAbstractTable $schema The signature of this * argument will be changed to {@see AbstractTable} in future release. - * @return AbstractColumn + * * @throws \ReflectionException + * + * @return AbstractColumn */ protected function declareColumn(SpiralAbstractTable $schema): AbstractColumn { diff --git a/src/OperationInterface.php b/src/OperationInterface.php index b79d2f0..d7412c2 100644 --- a/src/OperationInterface.php +++ b/src/OperationInterface.php @@ -30,8 +30,9 @@ public function getTable(): string; /** * Execute operation in a given capsule. * - * @param SpiralCapsuleInterface|CapsuleInterface $capsule The signature of this + * @param CapsuleInterface|SpiralCapsuleInterface $capsule The signature of this * argument will be changed to {@see CapsuleInterface} in future release. + * * @throws OperationException */ public function execute(SpiralCapsuleInterface $capsule); diff --git a/src/TableBlueprint.php b/src/TableBlueprint.php index 31be2af..9cbb461 100644 --- a/src/TableBlueprint.php +++ b/src/TableBlueprint.php @@ -35,7 +35,7 @@ final class TableBlueprint private $table = ''; /** - * @param SpiralCapsuleInterface|CapsuleInterface $capsule The signature of this + * @param CapsuleInterface|SpiralCapsuleInterface $capsule The signature of this * argument will be changed to {@see CapsuleInterface} in future release. * @param string $table */ @@ -308,8 +308,9 @@ public function rename(string $newName): void /** * Register new operation. * - * @param SpiralOperationInterface|OperationInterface $operation The signature + * @param OperationInterface|SpiralOperationInterface $operation The signature * of this argument will be changed to {@see OperationInterface} in future release. + * * @return TableBlueprint */ public function addOperation(SpiralOperationInterface $operation): self From 201d8add242fc03002d4eda84a426bf3efa00243 Mon Sep 17 00:00:00 2001 From: SerafimArts Date: Tue, 12 Oct 2021 20:47:30 +0300 Subject: [PATCH 5/5] Add aliases preloading --- src/polyfill.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/polyfill.php b/src/polyfill.php index 2d494e4..84bd1d9 100644 --- a/src/polyfill.php +++ b/src/polyfill.php @@ -22,3 +22,16 @@ class_alias($original, $class); } }); + +// Preload some aliases +class_exists(\Spiral\Database\Database::class); +class_exists(\Spiral\Database\DatabaseManager::class); +class_exists(\Spiral\Database\Schema\AbstractTable::class); + +class_exists(\Spiral\Migrations\State::class); +class_exists(\Spiral\Migrations\Config\MigrationConfig::class); + +interface_exists(\Spiral\Migrations\CapsuleInterface::class); +interface_exists(\Spiral\Migrations\OperationInterface::class); +interface_exists(\Spiral\Migrations\RepositoryInterface::class); +interface_exists(\Spiral\Migrations\Atomizer\RendererInterface::class);