Issues (155)

src/Commands/InfoCommand.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace wapmorgan\UnifiedArchive\Commands;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use wapmorgan\UnifiedArchive\Abilities;
8
9
class InfoCommand extends BaseArchiveCommand
10
{
11
    protected static $defaultName = 'archive:info';
12
13
    protected function configure()
14
    {
15
        parent::configure();
16
        $this
17
            ->setDescription('Renders archive info')
18
            ->setHelp('Renders archive info.')
19
        ;
20
    }
21
22
    /**
23
     * @throws \Exception
24
     */
25
    public function execute(InputInterface $input, OutputInterface $output)
26
    {
27
        $file = realpath($input->getArgument('archive'));
0 ignored issues
show
It seems like $input->getArgument('archive') can also be of type null and string[]; however, parameter $path of realpath() 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
        $file = realpath(/** @scrutinizer ignore-type */ $input->getArgument('archive'));
Loading history...
28
        $archive = $this->getArchive($input, $output);
29
30
        $output->writeln('Filename: ' . $file . ' (changed <comment>' . $this->formatDate(filemtime($file)) . '</comment>)');
31
        $output->writeln('Type: <info>' . $archive->getFormat() . '</info>, mime <info>' . $archive->getMimeType() . '</info> (via driver <comment>' . $archive->getDriverType() . '</comment>)');
32
        $output->writeln('Contains: ' . $archive->countFiles() . ' file' . ($archive->countFiles() > 1 ? 's' : null));
33
        $output->writeln('Size:');
34
        $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2)));
35
        $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2)));
36
        $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)');
37
        if ($archive->can(Abilities::GET_COMMENT) && !empty($comment = $archive->getComment()))
0 ignored issues
show
Are you sure the assignment to $comment is correct as $archive->getComment() targeting wapmorgan\UnifiedArchive...edArchive::getComment() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
            $output->writeln('Comment: <comment>' . $comment . '</comment>');
39
40
        return 0;
41
    }
42
}
43