Issues (155)

src/Commands/TestCommand.php (2 issues)

1
<?php
2
3
namespace wapmorgan\UnifiedArchive\Commands;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class TestCommand extends BaseArchiveCommand
10
{
11
    protected static $defaultName = 'files:test';
12
13
    protected function configure()
14
    {
15
        parent::configure();
16
        $this
17
            ->setDescription('Tests archive contents')
18
            ->setHelp('Tests archive contents.')
19
            ->addArgument('filter', InputArgument::OPTIONAL, 'Files filter (as for fnmatch). If no * passed in filter, it will be added at the end of filter')
20
        ;
21
    }
22
23
    public function execute(InputInterface $input, OutputInterface $output)
24
    {
25
        $archive = $this->getArchive($input, $output);
26
        $files = $archive->getFiles($input->getArgument('filter'));
0 ignored issues
show
It seems like $input->getArgument('filter') can also be of type string[]; however, parameter $filter of wapmorgan\UnifiedArchive...fiedArchive::getFiles() does only seem to accept null|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

26
        $files = $archive->getFiles(/** @scrutinizer ignore-type */ $input->getArgument('filter'));
Loading history...
27
28
        $errored = [];
29
        foreach ($files as $file) {
30
            $output->write($file . ' ... ');
31
            if ($archive->test($file, $hash) === true) {
32
                $output->writeln('<info>ok</info>');
33
            } else {
34
                $errored[] = $file;
35
                $output->writeln('<error>error</error>');
36
                var_dump($hash[$file]);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($hash[$file]) looks like debug code. Are you sure you do not want to remove it?
Loading history...
37
            }
38
        }
39
40
        if (!empty($errored)) {
41
            return 1;
42
        }
43
44
        return 0;
45
    }
46
}
47