diff --git a/src/Command/CreateCommand.php b/src/Command/CreateCommand.php index 9745856..fe87ac3 100644 --- a/src/Command/CreateCommand.php +++ b/src/Command/CreateCommand.php @@ -59,7 +59,7 @@ * ./yii migrate:create post --command=table --path=@root/migrations/blog * ``` * - * In case {@see createPath} is not set and no namespace is provided, {@see createNamespace} will be used. + * In case {@see $createPath} is not set and no namespace is provided, {@see $createNamespace} will be used. */ #[AsCommand('migrate:create', 'Creates a new migration.')] final class CreateCommand extends Command @@ -101,8 +101,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespace = $input->getOption('namespace'); if ($path !== null || $namespace !== null) { - $this->migrationService->createPath((string) $path); - $this->migrationService->createNamespace((string) $namespace); + $this->migrationService->setCreatePath((string) $path); + $this->migrationService->setCreateNamespace((string) $namespace); } else { $namespace = $this->migrationService->getCreateNamespace(); } diff --git a/src/Command/NewCommand.php b/src/Command/NewCommand.php index 7c26fba..e2e1a86 100644 --- a/src/Command/NewCommand.php +++ b/src/Command/NewCommand.php @@ -66,8 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespaces = $input->getOption('namespace'); if (!empty($paths) || !empty($namespaces)) { - $this->migrationService->updatePaths($paths); - $this->migrationService->updateNamespaces($namespaces); + $this->migrationService->setUpdatePaths($paths); + $this->migrationService->setUpdateNamespaces($namespaces); } $this->migrationService->before(self::getDefaultName() ?? ''); diff --git a/src/Command/UpdateCommand.php b/src/Command/UpdateCommand.php index f68be8f..ffbdbc1 100644 --- a/src/Command/UpdateCommand.php +++ b/src/Command/UpdateCommand.php @@ -70,8 +70,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespaces = $input->getOption('namespace'); if (!empty($paths) || !empty($namespaces)) { - $this->migrationService->updatePaths($paths); - $this->migrationService->updateNamespaces($namespaces); + $this->migrationService->setUpdatePaths($paths); + $this->migrationService->setUpdateNamespaces($namespaces); } if ($this->migrationService->before(self::getDefaultName() ?? '') === Command::INVALID) { diff --git a/src/Service/MigrationService.php b/src/Service/MigrationService.php index 6b96b7a..ba3221c 100644 --- a/src/Service/MigrationService.php +++ b/src/Service/MigrationService.php @@ -70,8 +70,8 @@ public function setIO(?SymfonyStyle $io): void /** * This method is invoked right before an action is to be executed (after all possible filters.) * - * It checks the existence of the {@see createPath}, {@see updatePaths}, {@see createNamespace}, - * {@see updateNamespaces}. + * It checks the existence of the {@see $createPath}, {@see $updatePaths}, {@see $createNamespace}, + * {@see $updateNamespaces}. * * @return int Whether the action should continue to be executed. */ @@ -182,7 +182,7 @@ public function getNewMigrations(): array * * @psalm-param string[] $value */ - public function updateNamespaces(array $value): void + public function setUpdateNamespaces(array $value): void { $this->updateNamespaces = $value; } @@ -193,12 +193,12 @@ public function updateNamespaces(array $value): void * This can be either a [path alias](guide:concept-aliases) or a directory path. * * Migration classes located at this path should be declared without a namespace. - * Use {@see createNamespace} property in case you are using namespaced migrations. + * Use {@see $createNamespace} property in case you are using namespaced migrations. * - * If you have set up {@see createNamespace}, you may set this field to `null` in order to disable usage of migrations + * If you have set up {@see $createNamespace}, you may set this field to `null` in order to disable usage of migrations * that are not namespaced. * - * In general, to load migrations from different locations, {@see createNamespace} is the preferable solution as the + * In general, to load migrations from different locations, {@see $createNamespace} is the preferable solution as the * migration name contains the origin of the migration in the history, which is not the case when using multiple * migration paths. * @@ -207,7 +207,7 @@ public function updateNamespaces(array $value): void * * @psalm-param string[] $value */ - public function updatePaths(array $value): void + public function setUpdatePaths(array $value): void { $this->updatePaths = $value; } @@ -318,12 +318,12 @@ public function makeRevertibleMigrations(array $classes): array ); } - public function createNamespace(string $value): void + public function setCreateNamespace(string $value): void { $this->createNamespace = $value; } - public function createPath(string $value): void + public function setCreatePath(string $value): void { $this->createPath = $value; } diff --git a/tests/Common/Command/AbstractCreateCommandTest.php b/tests/Common/Command/AbstractCreateCommandTest.php index caaec37..b306a5d 100644 --- a/tests/Common/Command/AbstractCreateCommandTest.php +++ b/tests/Common/Command/AbstractCreateCommandTest.php @@ -996,7 +996,7 @@ public function testIncorrectCreatePath(): void { MigrationHelper::useMigrationsPath($this->container); - $this->container->get(MigrationService::class)->createPath(__DIR__ . '/not-exists'); + $this->container->get(MigrationService::class)->setCreatePath(__DIR__ . '/not-exists'); $command = $this->createCommand($this->container); $command->setInputs(['yes']); @@ -1012,7 +1012,7 @@ public function testWithoutCreatePath(): void { MigrationHelper::useMigrationsPath($this->container); - $this->container->get(MigrationService::class)->createPath(''); + $this->container->get(MigrationService::class)->setCreatePath(''); $command = $this->createCommand($this->container); $command->setInputs(['yes']); @@ -1032,7 +1032,7 @@ public function testIncorrectCreateNamespace(): void MigrationHelper::useMigrationsNamespace($this->container); $this->container->get(MigrationService::class) - ->createNamespace('Yiisoft\\Db\\Migration\\TestsRuntime\\NotExists'); + ->setCreateNamespace('Yiisoft\\Db\\Migration\\TestsRuntime\\NotExists'); $command = $this->createCommand($this->container); $command->setInputs(['yes']); @@ -1048,7 +1048,7 @@ public function testWithoutCreateNamespace(): void { MigrationHelper::useMigrationsNamespace($this->container); - $this->container->get(MigrationService::class)->createNamespace(''); + $this->container->get(MigrationService::class)->setCreateNamespace(''); $command = $this->createCommand($this->container); $command->setInputs(['yes']); diff --git a/tests/Common/Command/AbstractUpdateCommandTest.php b/tests/Common/Command/AbstractUpdateCommandTest.php index 5e912d6..7bcdfbb 100644 --- a/tests/Common/Command/AbstractUpdateCommandTest.php +++ b/tests/Common/Command/AbstractUpdateCommandTest.php @@ -271,7 +271,7 @@ public function testWithoutUpdatePath(): void { MigrationHelper::useMigrationsPath($this->container); - $this->container->get(MigrationService::class)->updatePaths([]); + $this->container->get(MigrationService::class)->setUpdatePaths([]); $command = $this->createCommand($this->container); $command->setInputs(['yes']); @@ -290,7 +290,7 @@ public function testWithoutUpdateNamespaces(): void { MigrationHelper::useMigrationsNamespace($this->container); - $this->container->get(MigrationService::class)->updateNamespaces([]); + $this->container->get(MigrationService::class)->setUpdateNamespaces([]); $command = $this->createCommand($this->container); $command->setInputs(['yes']); diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index 082ec9e..e0472d9 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -46,7 +46,7 @@ public function testGetNewMigrationsWithNotExistNamespace(): void $service = $this->container->get(MigrationService::class); - $service->updateNamespaces([ + $service->setUpdateNamespaces([ MigrationHelper::NAMESPACE, 'Yiisoft\\Db\\Migration\\TestsRuntime\\NotExists', ]); diff --git a/tests/Support/Helper/MigrationHelper.php b/tests/Support/Helper/MigrationHelper.php index 6dfea2e..a29ae50 100644 --- a/tests/Support/Helper/MigrationHelper.php +++ b/tests/Support/Helper/MigrationHelper.php @@ -26,8 +26,8 @@ public static function useMigrationsPath(ContainerInterface $container): string { $service = $container->get(MigrationService::class); - $service->createPath(self::PATH_ALIAS); - $service->updatePaths([self::PATH_ALIAS]); + $service->setCreatePath(self::PATH_ALIAS); + $service->setUpdatePaths([self::PATH_ALIAS]); self::preparePaths($container); @@ -41,8 +41,8 @@ public static function useMigrationsNamespace(ContainerInterface $container): st { $service = $container->get(MigrationService::class); - $service->createNamespace(self::NAMESPACE); - $service->updateNamespaces([self::NAMESPACE]); + $service->setCreateNamespace(self::NAMESPACE); + $service->setUpdateNamespaces([self::NAMESPACE]); self::preparePaths($container); @@ -136,9 +136,9 @@ public static function resetPathAndNamespace(ContainerInterface $container): voi { $service = $container->get(MigrationService::class); - $service->createPath(''); - $service->updatePaths([]); - $service->createNamespace(''); - $service->updateNamespaces([]); + $service->setCreatePath(''); + $service->setUpdatePaths([]); + $service->setCreateNamespace(''); + $service->setUpdateNamespaces([]); } }