Skip to content

Commit 4440725

Browse files
ybenhssaienwouterj
authored andcommitted
Section method only in ConsoleOutputInterface
1 parent b73b941 commit 4440725

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

console.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,18 @@ which returns an instance of
181181
{
182182
protected function execute(InputInterface $input, OutputInterface $output)
183183
{
184+
// The section() method is only available in classes that implement ConsoleOutputInterface
185+
if (!$output instanceof ConsoleOutputInterface) {
186+
throw new LogicException(sprintf(
187+
'This command accepts only an instance of "%s", an instance of "%s" is given',
188+
ConsoleOutputInterface::class,
189+
\get_class($output)
190+
));
191+
}
192+
184193
$section1 = $output->section();
185194
$section2 = $output->section();
195+
186196
$section1->writeln('Hello');
187197
$section2->writeln('World!');
188198
// Output displays "Hello\nWorld!\n"

0 commit comments

Comments
 (0)