zhaojs
2023-07-31 8dcfae4fff98fbbb19ff46bd9750f25bc56801a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
 
namespace think\composer;
 
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use React\Promise\PromiseInterface;
 
abstract class LibraryInstaller extends \Composer\Installer\LibraryInstaller
{
    public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        return $this->makePromise(parent::install($repo, $package));
    }
 
    public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
    {
        return $this->makePromise(parent::update($repo, $initial, $target));
    }
 
    protected function makePromise($promise)
    {
        if ($promise instanceof PromiseInterface) {
            return $promise;
        }
        return new Promise();
    }
}