Issues (21)

src/Command/DropCollectionCommand.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Command;
6
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class DropCollectionCommand.
13
 */
14
class DropCollectionCommand extends AbstractCommand
15
{
16
    /**
17 8
     * {@inheritdoc}
18
     */
19 8
    protected function configure()
20
    {
21 8
        parent::configure();
22 8
        $this
23 8
            ->setName('mongodb:collection:drop')
24 8
            ->addArgument('collection', InputArgument::REQUIRED, 'collection to drop')
25
            ->setDescription('Drops a database');
26
    }
27
28
    /**
29 1
     * {@inheritdoc}
30
     */
31 1
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33 1
        $collection = $input->getArgument('collection');
34 1
35 1
        $this->io->writeln(sprintf('Dropping collection %s', $collection));
0 ignored issues
show
It seems like $collection can also be of type string[]; however, parameter $values of sprintf() does only seem to accept double|integer|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

35
        $this->io->writeln(sprintf('Dropping collection %s', /** @scrutinizer ignore-type */ $collection));
Loading history...
36 1
        $this->connection->dropCollection($collection);
0 ignored issues
show
It seems like $collection can also be of type string[]; however, parameter $collectionName of MongoDB\Database::dropCollection() 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

36
        $this->connection->dropCollection(/** @scrutinizer ignore-type */ $collection);
Loading history...
37
        $this->io->writeln('Collection dropped');
38
39
        return 0;
40
    }
41
}
42