Skip to content

Commit 73f02f1

Browse files
committed
[#14550] Reduce nr of lines used for exception
1 parent 6f13815 commit 73f02f1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

console.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,19 @@ called "output sections". Create one or more of these sections when you need to
173173
clear and overwrite the output information.
174174

175175
Sections are created with the
176-
:method:`Symfony\\Component\\Console\\Output\\ConsoleOutput::section` method,
177-
which returns an instance of
176+
:method:`ConsoleOutput::section() <Symfony\\Component\\Console\\Output\\ConsoleOutput::section>`
177+
method, which returns an instance of
178178
:class:`Symfony\\Component\\Console\\Output\\ConsoleSectionOutput`::
179179

180+
// ...
181+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
182+
180183
class MyCommand extends Command
181184
{
182185
protected function execute(InputInterface $input, OutputInterface $output)
183186
{
184-
// The section() method is only available in classes that implement ConsoleOutputInterface
185187
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-
));
188+
throw new \LogicException('This command accepts only an instance of "ConsoleOutputInterface".');
191189
}
192190

193191
$section1 = $output->section();

0 commit comments

Comments
 (0)