@@ -10,10 +10,9 @@ When a lot of logging has to happen, it's cumbersome to print information
10
10
depending on the verbosity settings (``-v ``, ``-vv ``, ``-vvv ``) because the
11
11
calls need to be wrapped in conditions. For example::
12
12
13
- use Symfony\Component\Console\Input\InputInterface;
14
13
use Symfony\Component\Console\Output\OutputInterface;
15
14
16
- protected function execute(InputInterface $input, OutputInterface $output): int
15
+ public function __invoke( OutputInterface $output): int
17
16
{
18
17
if ($output->isDebug()) {
19
18
$output->writeln('Some info');
@@ -34,13 +33,12 @@ the current log level and the console verbosity.
34
33
35
34
The example above could then be rewritten as::
36
35
37
- // src/Command/YourCommand .php
36
+ // src/Command/MyCommand .php
38
37
namespace App\Command;
39
38
40
39
use Psr\Log\LoggerInterface;
41
40
use Symfony\Component\Console\Attribute\AsCommand;
42
41
use Symfony\Component\Console\Command\Command;
43
- use Symfony\Component\Console\Style\SymfonyStyle;
44
42
45
43
#[AsCommand(name: 'app:my-command')]
46
44
class MyCommand
@@ -50,7 +48,7 @@ The example above could then be rewritten as::
50
48
) {
51
49
}
52
50
53
- public function __invoke(SymfonyStyle $io ): int
51
+ public function __invoke(): int
54
52
{
55
53
$this->logger->debug('Some info');
56
54
$this->logger->notice('Some more info');
0 commit comments