Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9cfc356

Browse files
committed
Throw exception if not instanceof ConsoleOutupuInterface
1 parent83b430d commit9cfc356

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎console.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,17 @@ which returns an instance of
196196
protected function execute(InputInterface $input, OutputInterface $output)
197197
{
198198
// The section() method is only available in classes that implement ConsoleOutputInterface
199-
if ($output instanceof ConsoleOutputInterface) {
200-
$section1 = $output->section();
201-
$section2 = $output->section();
202-
} else {
203-
$section1 = $section2 = $output;
199+
if (!$output instanceof ConsoleOutputInterface) {
200+
throw new LogicException(sprintf(
201+
'This command accepts only an instance of "%s", an instance of "%s" is given',
202+
ConsoleOutputInterface::class,
203+
\get_class($output)
204+
));
204205
}
205-
206+
207+
$section1 = $output->section();
208+
$section2 = $output->section();
209+
206210
$section1->writeln('Hello');
207211
$section2->writeln('World!');
208212
// Output displays "Hello\nWorld!\n"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp