Issues (83)

Command/StorageTrait.php (1 issue)

Labels
Severity
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Bundle\Command;
13
14
use Translation\Bundle\Service\StorageManager;
15
use Translation\Bundle\Service\StorageService;
16
17
trait StorageTrait
18
{
19
    /**
20
     * @var StorageManager
21
     */
22
    private $storageManager;
23
24
    /**
25
     * @param string|string[]|null $configName
26
     *
27
     * @throws \InvalidArgumentException
28
     */
29
    private function getStorage($configName): StorageService
30
    {
31
        if (null === $storage = $this->storageManager->getStorage($configName)) {
32
            $availableStorages = $this->storageManager->getNames();
33
34
            throw new \InvalidArgumentException(\sprintf('Unknown storage "%s". Available storages are "%s".', $configName, \implode('", "', $availableStorages)));
0 ignored issues
show
It seems like $configName 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

34
            throw new \InvalidArgumentException(\sprintf('Unknown storage "%s". Available storages are "%s".', /** @scrutinizer ignore-type */ $configName, \implode('", "', $availableStorages)));
Loading history...
35
        }
36
37
        return $storage;
38
    }
39
}
40