Issues (13)

src/Console/CacheDestroyCommand.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace SimpleDIC\Console;
4
5
use SimpleDIC\DIC;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class CacheDestroyCommand extends Command
12
{
13
    protected function configure()
14
    {
15
        $this
16
            ->setName('dic:cache-destroy')
17
            ->setDescription('Destroy the cache created by DIC.')
18
            ->setHelp('This command try to destroy cache files created by DIC and clear apcu cache.')
19
            ->addArgument('cache_dir', InputArgument::OPTIONAL)
20
        ;
21
    }
22
23
    protected function execute(InputInterface $input, OutputInterface $output)
24
    {
25
        $cacheDir = !empty($input->getArgument('cache_dir')) ? $input->getArgument('cache_dir') : __DIR__.'/../../_cache';
26
27
        DIC::destroyCacheDir($cacheDir);
0 ignored issues
show
It seems like $cacheDir can also be of type string[]; however, parameter $cacheDir of SimpleDIC\DIC::destroyCacheDir() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        DIC::destroyCacheDir(/** @scrutinizer ignore-type */ $cacheDir);
Loading history...
28
29
        $output->writeln('<fg=green>Cache was successfully cleared.</>');
30
    }
31
}
32