From 06c869987cc18f6a9c2b3b8c8d2461100c723ad7 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 9 Jul 2025 10:56:23 +0200 Subject: [PATCH 1/2] Fix up wrapper usage for io. --- composer.json | 2 +- src/Command/AllCommand.php | 6 +++--- src/Command/EntryCommand.php | 10 +++++----- src/Command/PluginCommand.php | 6 +++--- src/Command/SimpleBakeCommand.php | 2 +- src/Command/TemplateCommand.php | 2 +- src/Command/TestCommand.php | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/composer.json b/composer.json index fedab7a3..6d5f6b26 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "require-dev": { "cakephp/cakephp-codesniffer": "^5.0.0", "cakephp/debug_kit": "^5.0.0", - "phpunit/phpunit": "^10.5.5 || ^11.1.3" + "phpunit/phpunit": "^10.5.40 || ^11.5.20 || ^12.2.4" }, "autoload": { "psr-4": { diff --git a/src/Command/AllCommand.php b/src/Command/AllCommand.php index 0c046502..41fb43c9 100644 --- a/src/Command/AllCommand.php +++ b/src/Command/AllCommand.php @@ -124,16 +124,16 @@ public function execute(Arguments $args, ConsoleIo $io): ?int } $message = sprintf('Error generating %s for %s: %s', $commandName, $table, $e->getMessage()); - $io->err('' . $message . ''); + $io->error($message); $errors++; } } } if ($errors) { - $io->out(sprintf('Bake All completed, but with %s errors.', $errors), 1, ConsoleIo::NORMAL); + $io->warning(sprintf('Bake All completed, but with %s errors.', $errors), 1, ConsoleIo::NORMAL); } else { - $io->out('Bake All complete.', 1, ConsoleIo::NORMAL); + $io->success('Bake All complete.', 1, ConsoleIo::NORMAL); } return $errors ? static::CODE_ERROR : static::CODE_SUCCESS; diff --git a/src/Command/EntryCommand.php b/src/Command/EntryCommand.php index 87b9dd75..7c2d1c7d 100644 --- a/src/Command/EntryCommand.php +++ b/src/Command/EntryCommand.php @@ -82,7 +82,7 @@ public function run(array $argv, ConsoleIo $io): ?int $parser->argumentNames(), ); } catch (ConsoleException $e) { - $io->err('Error: ' . $e->getMessage()); + $io->error('Error: ' . $e->getMessage()); return static::CODE_ERROR; } @@ -109,14 +109,14 @@ public function execute(Arguments $args, ConsoleIo $io): ?int { if ($args->hasArgumentAt(0)) { $name = $args->getArgumentAt(0); - $io->err( - "Could not find bake command named `$name`." - . ' Run `bake --help` to get a list of commands.', + $io->error( + "Could not find bake command named `$name`." + . ' Run `bake --help` to get a list of commands.', ); return static::CODE_ERROR; } - $io->err('No command provided. Run `bake --help` to get a list of commands.'); + $io->warning('No command provided. Run `bake --help` to get a list of commands.'); return static::CODE_ERROR; } diff --git a/src/Command/PluginCommand.php b/src/Command/PluginCommand.php index 341f73e3..66bf1e33 100644 --- a/src/Command/PluginCommand.php +++ b/src/Command/PluginCommand.php @@ -56,8 +56,8 @@ public function execute(Arguments $args, ConsoleIo $io): ?int { $name = $args->getArgument('name'); if (empty($name)) { - $io->err('You must provide a plugin name in CamelCase format.'); - $io->err('To make an "MyExample" plugin, run `cake bake plugin MyExample`.'); + $io->error('You must provide a plugin name in CamelCase format.'); + $io->out('To make an "MyExample" plugin, run `cake bake plugin MyExample`.'); return static::CODE_ERROR; } @@ -70,7 +70,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int $this->isVendor = true; if (!is_dir($this->path)) { - $io->err(sprintf('Path `%s` does not exist.', $this->path)); + $io->error(sprintf('Path `%s` does not exist.', $this->path)); return static::CODE_ERROR; } diff --git a/src/Command/SimpleBakeCommand.php b/src/Command/SimpleBakeCommand.php index 35527749..2df9572a 100644 --- a/src/Command/SimpleBakeCommand.php +++ b/src/Command/SimpleBakeCommand.php @@ -78,7 +78,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int $this->extractCommonProperties($args); $name = $args->getArgumentAt(0); if (empty($name)) { - $io->err('You must provide a name to bake a ' . $this->name()); + $io->error('You must provide a name to bake a ' . $this->name()); $this->abort(); } $name = $this->_getName($name); diff --git a/src/Command/TemplateCommand.php b/src/Command/TemplateCommand.php index 558187ab..a57b051e 100644 --- a/src/Command/TemplateCommand.php +++ b/src/Command/TemplateCommand.php @@ -360,7 +360,7 @@ public function bake( } if (empty($content)) { // phpcs:ignore Generic.Files.LineLength - $io->err("No generated content for '{$template}.{$this->ext}', not generating template."); + $io->warning("No generated content for '{$template}.{$this->ext}', not generating template."); return; } diff --git a/src/Command/TestCommand.php b/src/Command/TestCommand.php index dd5e6c30..bc3c4292 100644 --- a/src/Command/TestCommand.php +++ b/src/Command/TestCommand.php @@ -124,7 +124,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int $name = $this->_getName($name); if ($this->bake($type, $name, $args, $io)) { - $io->out('Done'); + $io->success('Done'); } return static::CODE_SUCCESS; @@ -188,13 +188,13 @@ protected function _bakeAll(string $type, Arguments $args, ConsoleIo $io): void foreach ($classes as $class) { if ($this->bake($type, $class, $args, $io)) { - $io->out('Done - ' . $class . ''); + $io->success('Done - ' . $class); } else { - $io->out('Failed - ' . $class . ''); + $io->error('Failed - ' . $class); } } - $io->out('Bake finished'); + $io->info('Bake finished'); } /** From 268fdf1b806683d39b2773a48b35d0ce630cd5ca Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 15 Jul 2025 00:07:58 +0200 Subject: [PATCH 2/2] Fix up wrapper usage for io. --- src/Command/AllCommand.php | 4 ++-- src/Command/BakeCommand.php | 2 +- src/Command/FixtureCommand.php | 2 +- src/Command/ModelCommand.php | 4 ++-- src/Command/TemplateCommand.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Command/AllCommand.php b/src/Command/AllCommand.php index 41fb43c9..8cccf7b4 100644 --- a/src/Command/AllCommand.php +++ b/src/Command/AllCommand.php @@ -131,9 +131,9 @@ public function execute(Arguments $args, ConsoleIo $io): ?int } if ($errors) { - $io->warning(sprintf('Bake All completed, but with %s errors.', $errors), 1, ConsoleIo::NORMAL); + $io->warning(sprintf('Bake All completed, but with %s errors.', $errors)); } else { - $io->success('Bake All complete.', 1, ConsoleIo::NORMAL); + $io->success('Bake All complete.'); } return $errors ? static::CODE_ERROR : static::CODE_SUCCESS; diff --git a/src/Command/BakeCommand.php b/src/Command/BakeCommand.php index 930ac6b9..fe35f1b1 100644 --- a/src/Command/BakeCommand.php +++ b/src/Command/BakeCommand.php @@ -180,7 +180,7 @@ protected function deleteEmptyFile(string $path, ConsoleIo $io): void { if (file_exists($path)) { unlink($path); - $io->out(sprintf('Deleted `%s`', $path), 1, ConsoleIo::NORMAL); + $io->out(sprintf('Deleted `%s`', $path)); } } diff --git a/src/Command/FixtureCommand.php b/src/Command/FixtureCommand.php index b461cef2..94908eea 100644 --- a/src/Command/FixtureCommand.php +++ b/src/Command/FixtureCommand.php @@ -269,7 +269,7 @@ public function generateFixtureFile(Arguments $args, ConsoleIo $io, string $mode ->set($vars) ->generate('Bake.tests/fixture'); - $io->out("\n" . sprintf('Baking test fixture for %s...', $model), 1, ConsoleIo::NORMAL); + $io->out("\n" . sprintf('Baking test fixture for %s...', $model)); $io->createFile($path . $filename, $contents, $this->force); $emptyFile = $path . '.gitkeep'; $this->deleteEmptyFile($emptyFile, $io); diff --git a/src/Command/ModelCommand.php b/src/Command/ModelCommand.php index 48c45204..6605d23f 100644 --- a/src/Command/ModelCommand.php +++ b/src/Command/ModelCommand.php @@ -1146,7 +1146,7 @@ public function bakeEntity(Table $model, array $data, Arguments $args, ConsoleIo } $name = $this->_entityName($model->getAlias()); - $io->out("\n" . sprintf('Baking entity class for %s...', $name), 1, ConsoleIo::NORMAL); + $io->out("\n" . sprintf('Baking entity class for %s...', $name)); $namespace = Configure::read('App.namespace'); $pluginPath = ''; @@ -1198,7 +1198,7 @@ public function bakeTable(Table $model, array $data, Arguments $args, ConsoleIo } $name = $model->getAlias(); - $io->out("\n" . sprintf('Baking table class for %s...', $name), 1, ConsoleIo::NORMAL); + $io->out("\n" . sprintf('Baking table class for %s...', $name)); $namespace = Configure::read('App.namespace'); $pluginPath = ''; diff --git a/src/Command/TemplateCommand.php b/src/Command/TemplateCommand.php index a57b051e..0fad2240 100644 --- a/src/Command/TemplateCommand.php +++ b/src/Command/TemplateCommand.php @@ -367,7 +367,7 @@ public function bake( $path = $this->getTemplatePath($args); $filename = $path . Inflector::underscore($outputFile) . '.' . $this->ext; - $io->out("\n" . sprintf('Baking `%s` view template file...', $outputFile), 1, ConsoleIo::NORMAL); + $io->out("\n" . sprintf('Baking `%s` view template file...', $outputFile)); $io->createFile($filename, $content, $this->force); }