diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 04effec5dc18..7c60780cc31e 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -651,41 +651,6 @@ 'count' => 2, 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SessionMigrationGenerator\\:\\:generateClass\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SessionMigrationGenerator\\:\\:generateView\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Only booleans are allowed in &&, mixed given on the left side\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Only booleans are allowed in &&, mixed given on the right side\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Only booleans are allowed in a negated boolean, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/system/Commands/Generators/SessionMigrationGenerator.php', -]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 2, diff --git a/system/Commands/Generators/MigrateCreate.php b/system/Commands/Generators/MigrateCreate.php deleted file mode 100644 index 0b4935342831..000000000000 --- a/system/Commands/Generators/MigrateCreate.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Commands\Generators; - -use CodeIgniter\CLI\BaseCommand; -use CodeIgniter\CLI\CLI; - -/** - * Deprecated class for the migration creation command. - * - * @deprecated Use make:migration instead. - * - * @codeCoverageIgnore - */ -class MigrateCreate extends BaseCommand -{ - /** - * The group the command is lumped under - * when listing commands. - * - * @var string - */ - protected $group = 'Generators'; - - /** - * The Command's name - * - * @var string - */ - protected $name = 'migrate:create'; - - /** - * The Command's short description - * - * @var string - */ - protected $description = '[DEPRECATED] Creates a new migration file. Please use "make:migration" instead.'; - - /** - * The Command's usage - * - * @var string - */ - protected $usage = 'migrate:create [options]'; - - /** - * The Command's arguments. - * - * @var array - */ - protected $arguments = [ - 'name' => 'The migration file name.', - ]; - - /** - * The Command's options. - * - * @var array - */ - protected $options = [ - '--namespace' => 'Set root namespace. Defaults to APP_NAMESPACE', - '--force' => 'Force overwrite existing files.', - ]; - - /** - * Actually execute a command. - */ - public function run(array $params) - { - // Resolve arguments before passing to make:migration - $params[0] ??= CLI::getSegment(2); - - $params['namespace'] ??= CLI::getOption('namespace') ?? APP_NAMESPACE; - - if (array_key_exists('force', $params) || CLI::getOption('force')) { - $params['force'] = null; - } - - $this->call('make:migration', $params); - } -} diff --git a/system/Commands/Generators/SessionMigrationGenerator.php b/system/Commands/Generators/SessionMigrationGenerator.php deleted file mode 100644 index a04527e866d1..000000000000 --- a/system/Commands/Generators/SessionMigrationGenerator.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Commands\Generators; - -use CodeIgniter\CLI\BaseCommand; -use CodeIgniter\CLI\CLI; -use CodeIgniter\CLI\GeneratorTrait; -use Config\App; -use Config\Migrations; - -/** - * Generates a migration file for database sessions. - * - * @deprecated Use `make:migration --session` instead. - * - * @codeCoverageIgnore - */ -class SessionMigrationGenerator extends BaseCommand -{ - use GeneratorTrait; - - /** - * The Command's Group - * - * @var string - */ - protected $group = 'Generators'; - - /** - * The Command's Name - * - * @var string - */ - protected $name = 'session:migration'; - - /** - * The Command's Description - * - * @var string - */ - protected $description = '[DEPRECATED] Generates the migration file for database sessions, Please use "make:migration --session" instead.'; - - /** - * The Command's Usage - * - * @var string - */ - protected $usage = 'session:migration [options]'; - - /** - * The Command's Options - * - * @var array - */ - protected $options = [ - '-t' => 'Supply a table name.', - '-g' => 'Database group to use. Default: "default".', - ]; - - /** - * Actually execute a command. - */ - public function run(array $params) - { - $this->component = 'Migration'; - $this->directory = 'Database\Migrations'; - $this->template = 'migration.tpl.php'; - - $table = 'ci_sessions'; - - if (array_key_exists('t', $params) || CLI::getOption('t')) { - $table = $params['t'] ?? CLI::getOption('t'); - } - - $params[0] = "_create_{$table}_table"; - - $this->execute($params); - } - - /** - * Performs the necessary replacements. - */ - protected function prepare(string $class): string - { - $data = []; - $data['session'] = true; - $data['table'] = $this->getOption('t'); - $data['DBGroup'] = $this->getOption('g'); - $data['matchIP'] = config(App::class)->sessionMatchIP ?? false; - - $data['table'] = is_string($data['table']) ? $data['table'] : 'ci_sessions'; - $data['DBGroup'] = is_string($data['DBGroup']) ? $data['DBGroup'] : 'default'; - - return $this->parseTemplate($class, [], [], $data); - } - - /** - * Change file basename before saving. - */ - protected function basename(string $filename): string - { - return gmdate(config(Migrations::class)->timestampFormat) . basename($filename); - } -} diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index 78bc5415b8ed..372fb2f6c52a 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -90,7 +90,7 @@ public function testBadCommand(): void public function testHelpCommandDetails(): void { - $this->initCLI('help', 'session:migration'); + $this->initCLI('help', 'make:migration'); $console = new Console(); $console->run(); diff --git a/user_guide_src/source/changelogs/v4.5.0.rst b/user_guide_src/source/changelogs/v4.5.0.rst index 2b6fc7299231..48cd6ddf2ca2 100644 --- a/user_guide_src/source/changelogs/v4.5.0.rst +++ b/user_guide_src/source/changelogs/v4.5.0.rst @@ -127,6 +127,12 @@ Test - ``FeatureResponse`` - ``FeatureTestCase`` +Spark Commands +-------------- + +- ``migrate:create`` +- ``session:migration`` + Others ------ diff --git a/user_guide_src/source/cli/cli_generators.rst b/user_guide_src/source/cli/cli_generators.rst index 8636901644f2..3e11954b6d79 100644 --- a/user_guide_src/source/cli/cli_generators.rst +++ b/user_guide_src/source/cli/cli_generators.rst @@ -36,10 +36,6 @@ where ```` will be replaced with the command to check. namespace defined in your ``$psr4`` array in ``Config\Autoload`` or defined in your composer autoload file. Otherwise, code generation will be interrupted. -.. important:: Since v4.0.5, use of ``migrate:create`` to create migration files has been deprecated. It will be removed in - future releases. Please use ``make:migration`` as replacement. Also, please use ``make:migration --session`` - to use instead of the deprecated ``session:migration``. - ******************* Built-in Generators *******************