Skip to content

Commit 6fd15ae

Browse files
authored
Merge pull request #1045 from cakephp/3.x-cleanup-io
Fix up wrapper usage for io.
2 parents a0d2b96 + 268fdf1 commit 6fd15ae

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"require-dev": {
3232
"cakephp/cakephp-codesniffer": "^5.0.0",
3333
"cakephp/debug_kit": "^5.0.0",
34-
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
34+
"phpunit/phpunit": "^10.5.40 || ^11.5.20 || ^12.2.4"
3535
},
3636
"autoload": {
3737
"psr-4": {

src/Command/AllCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,16 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
124124
}
125125

126126
$message = sprintf('Error generating %s for %s: %s', $commandName, $table, $e->getMessage());
127-
$io->err('<error>' . $message . '</error>');
127+
$io->error($message);
128128
$errors++;
129129
}
130130
}
131131
}
132132

133133
if ($errors) {
134-
$io->out(sprintf('<warning>Bake All completed, but with %s errors.</warning>', $errors), 1, ConsoleIo::NORMAL);
134+
$io->warning(sprintf('Bake All completed, but with %s errors.', $errors));
135135
} else {
136-
$io->out('<success>Bake All complete.</success>', 1, ConsoleIo::NORMAL);
136+
$io->success('Bake All complete.');
137137
}
138138

139139
return $errors ? static::CODE_ERROR : static::CODE_SUCCESS;

src/Command/BakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected function deleteEmptyFile(string $path, ConsoleIo $io): void
180180
{
181181
if (file_exists($path)) {
182182
unlink($path);
183-
$io->out(sprintf('<success>Deleted</success> `%s`', $path), 1, ConsoleIo::NORMAL);
183+
$io->out(sprintf('<success>Deleted</success> `%s`', $path));
184184
}
185185
}
186186

src/Command/EntryCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function run(array $argv, ConsoleIo $io): ?int
8282
$parser->argumentNames(),
8383
);
8484
} catch (ConsoleException $e) {
85-
$io->err('Error: ' . $e->getMessage());
85+
$io->error('Error: ' . $e->getMessage());
8686

8787
return static::CODE_ERROR;
8888
}
@@ -109,14 +109,14 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
109109
{
110110
if ($args->hasArgumentAt(0)) {
111111
$name = $args->getArgumentAt(0);
112-
$io->err(
113-
"<error>Could not find bake command named `$name`."
114-
. ' Run `bake --help` to get a list of commands.</error>',
112+
$io->error(
113+
"Could not find bake command named `$name`."
114+
. ' Run `bake --help` to get a list of commands.',
115115
);
116116

117117
return static::CODE_ERROR;
118118
}
119-
$io->err('<warning>No command provided. Run `bake --help` to get a list of commands.</warning>');
119+
$io->warning('No command provided. Run `bake --help` to get a list of commands.');
120120

121121
return static::CODE_ERROR;
122122
}

src/Command/FixtureCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function generateFixtureFile(Arguments $args, ConsoleIo $io, string $mode
269269
->set($vars)
270270
->generate('Bake.tests/fixture');
271271

272-
$io->out("\n" . sprintf('Baking test fixture for %s...', $model), 1, ConsoleIo::NORMAL);
272+
$io->out("\n" . sprintf('Baking test fixture for %s...', $model));
273273
$io->createFile($path . $filename, $contents, $this->force);
274274
$emptyFile = $path . '.gitkeep';
275275
$this->deleteEmptyFile($emptyFile, $io);

src/Command/ModelCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ public function bakeEntity(Table $model, array $data, Arguments $args, ConsoleIo
11461146
}
11471147

11481148
$name = $this->_entityName($model->getAlias());
1149-
$io->out("\n" . sprintf('Baking entity class for %s...', $name), 1, ConsoleIo::NORMAL);
1149+
$io->out("\n" . sprintf('Baking entity class for %s...', $name));
11501150

11511151
$namespace = Configure::read('App.namespace');
11521152
$pluginPath = '';
@@ -1198,7 +1198,7 @@ public function bakeTable(Table $model, array $data, Arguments $args, ConsoleIo
11981198
}
11991199

12001200
$name = $model->getAlias();
1201-
$io->out("\n" . sprintf('Baking table class for %s...', $name), 1, ConsoleIo::NORMAL);
1201+
$io->out("\n" . sprintf('Baking table class for %s...', $name));
12021202

12031203
$namespace = Configure::read('App.namespace');
12041204
$pluginPath = '';

src/Command/PluginCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
5656
{
5757
$name = $args->getArgument('name');
5858
if (empty($name)) {
59-
$io->err('<error>You must provide a plugin name in CamelCase format.</error>');
60-
$io->err('To make an "MyExample" plugin, run <info>`cake bake plugin MyExample`</info>.');
59+
$io->error('You must provide a plugin name in CamelCase format.');
60+
$io->out('To make an "MyExample" plugin, run <info>`cake bake plugin MyExample`</info>.');
6161

6262
return static::CODE_ERROR;
6363
}
@@ -70,7 +70,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
7070
$this->isVendor = true;
7171

7272
if (!is_dir($this->path)) {
73-
$io->err(sprintf('Path `%s` does not exist.', $this->path));
73+
$io->error(sprintf('Path `%s` does not exist.', $this->path));
7474

7575
return static::CODE_ERROR;
7676
}

src/Command/SimpleBakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
7878
$this->extractCommonProperties($args);
7979
$name = $args->getArgumentAt(0);
8080
if (empty($name)) {
81-
$io->err('You must provide a name to bake a ' . $this->name());
81+
$io->error('You must provide a name to bake a ' . $this->name());
8282
$this->abort();
8383
}
8484
$name = $this->_getName($name);

src/Command/TemplateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@ public function bake(
360360
}
361361
if (empty($content)) {
362362
// phpcs:ignore Generic.Files.LineLength
363-
$io->err("<warning>No generated content for '{$template}.{$this->ext}', not generating template.</warning>");
363+
$io->warning("No generated content for '{$template}.{$this->ext}', not generating template.");
364364

365365
return;
366366
}
367367
$path = $this->getTemplatePath($args);
368368
$filename = $path . Inflector::underscore($outputFile) . '.' . $this->ext;
369369

370-
$io->out("\n" . sprintf('Baking `%s` view template file...', $outputFile), 1, ConsoleIo::NORMAL);
370+
$io->out("\n" . sprintf('Baking `%s` view template file...', $outputFile));
371371
$io->createFile($filename, $content, $this->force);
372372
}
373373

src/Command/TestCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
124124
$name = $this->_getName($name);
125125

126126
if ($this->bake($type, $name, $args, $io)) {
127-
$io->out('<success>Done</success>');
127+
$io->success('Done');
128128
}
129129

130130
return static::CODE_SUCCESS;
@@ -188,13 +188,13 @@ protected function _bakeAll(string $type, Arguments $args, ConsoleIo $io): void
188188

189189
foreach ($classes as $class) {
190190
if ($this->bake($type, $class, $args, $io)) {
191-
$io->out('<success>Done - ' . $class . '</success>');
191+
$io->success('Done - ' . $class);
192192
} else {
193-
$io->out('<error>Failed - ' . $class . '</error>');
193+
$io->error('Failed - ' . $class);
194194
}
195195
}
196196

197-
$io->out('<info>Bake finished</info>');
197+
$io->info('Bake finished');
198198
}
199199

200200
/**

0 commit comments

Comments
 (0)