Issues (13)

src/Compatibility/DependenciesFactory.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Compatibility;
7
8
use Composer\Downloader\FileDownloader;
9
10
class DependenciesFactory
11
{
12
    public function createCompositeRepository($repository)
13
    {
14
        if (version_compare(\Composer\Composer::getVersion(), '2.0', '<')) {
15
            return new \Composer\Repository\CompositeRepository(array($repository));
16
        }
17
18
        return  new \Composer\Repository\InstalledRepository(array($repository));
19
    }
20
21
    public function createFileDownloader($appIO, $composer, $composerConfig, $cache)
22
    {
23
        if (version_compare(\Composer\Composer::getVersion(), '2.0', '<')) {
24
            return new FileDownloader($appIO, $composerConfig, null, $cache);
0 ignored issues
show
null of type null is incompatible with the type Composer\Util\HttpDownloader expected by parameter $httpDownloader of Composer\Downloader\FileDownloader::__construct(). ( Ignorable by Annotation )

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

24
            return new FileDownloader($appIO, $composerConfig, /** @scrutinizer ignore-type */ null, $cache);
Loading history...
25
        }
26
27
        $httpDownloader = $composer->getLoop()->getHttpDownloader();
28
        return new FileDownloader($appIO, $composerConfig, $httpDownloader, null, $cache);
29
    }
30
31
    public function createPackageDownloader($baseDownloader, $package)
32
    {
33
        if (version_compare(\Composer\Composer::getVersion(), '2.0', '<')) {
34
            return $baseDownloader->getDownloaderForInstalledPackage($package);
35
        }
36
37
        return $baseDownloader->getDownloaderForPackage($package);
38
    }
39
}
40