1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* hirak/prestissimo |
4
|
|
|
* @author Hiraku NAKANO |
5
|
|
|
* @license MIT https://github.com/hirak/prestissimo |
6
|
|
|
*/ |
7
|
|
|
namespace Hirak\Prestissimo; |
8
|
|
|
|
9
|
|
|
use Composer\Composer; |
10
|
|
|
use Composer\IO; |
11
|
|
|
use Composer\Plugin as CPlugin; |
12
|
|
|
use Composer\EventDispatcher; |
13
|
|
|
use Composer\Package; |
14
|
|
|
use Composer\Installer; |
15
|
|
|
use Composer\DependencyResolver; |
16
|
|
|
|
17
|
|
|
class Plugin implements |
18
|
|
|
CPlugin\PluginInterface, |
19
|
|
|
EventDispatcher\EventSubscriberInterface |
20
|
|
|
{ |
21
|
|
|
/** @var IO\IOInterface */ |
22
|
|
|
private $io; |
23
|
|
|
|
24
|
|
|
/** @var Composer\Config */ |
25
|
|
|
private $config; |
26
|
|
|
|
27
|
|
|
/** @var boolean */ |
28
|
|
|
private $disabled = false; |
29
|
|
|
|
30
|
|
|
private static $pluginClasses = array( |
31
|
|
|
'CopyRequest', |
32
|
|
|
'CurlMulti', |
33
|
|
|
'ConfigFacade', |
34
|
|
|
'FetchException', |
35
|
|
|
'FileDownloaderDummy', |
36
|
|
|
'Plugin', |
37
|
|
|
'Prefetcher', |
38
|
|
|
); |
39
|
|
|
|
40
|
2 |
|
public function activate(Composer $composer, IO\IOInterface $io) |
41
|
|
|
{ |
42
|
|
|
// @codeCoverageIgnoreStart |
43
|
|
|
// guard for self-update problem |
44
|
|
|
if (__CLASS__ !== 'Hirak\Prestissimo\Plugin') { |
45
|
|
|
return $this->disable(); |
46
|
|
|
} |
47
|
|
|
// @codeCoverageIgnoreEnd |
48
|
|
|
|
49
|
|
|
// load all classes |
50
|
2 |
|
foreach (self::$pluginClasses as $class) { |
51
|
2 |
|
class_exists(__NAMESPACE__ . '\\' . $class); |
52
|
2 |
|
} |
53
|
|
|
|
54
|
2 |
|
$this->io = $io; |
55
|
2 |
|
$this->config = $composer->getConfig(); |
|
|
|
|
56
|
2 |
|
} |
57
|
|
|
|
58
|
1 |
|
public static function getSubscribedEvents() |
59
|
|
|
{ |
60
|
|
|
return array( |
61
|
1 |
|
Installer\InstallerEvents::POST_DEPENDENCIES_SOLVING => array( |
62
|
1 |
|
array('onPostDependenciesSolving', PHP_INT_MAX), |
63
|
1 |
|
), |
64
|
1 |
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* pre-fetch parallel by curl_multi |
69
|
|
|
*/ |
70
|
1 |
|
public function onPostDependenciesSolving(Installer\InstallerEvent $ev) |
71
|
|
|
{ |
72
|
1 |
|
if ($this->disabled) { |
73
|
1 |
|
return; |
74
|
|
|
} |
75
|
1 |
|
$prefetcher = new Prefetcher; |
76
|
1 |
|
$prefetcher->fetchAllFromOperations( |
77
|
1 |
|
$this->io, |
78
|
1 |
|
$this->config, |
79
|
1 |
|
$ev->getOperations() |
80
|
1 |
|
); |
81
|
1 |
|
} |
82
|
|
|
|
83
|
1 |
|
public function disable() |
84
|
|
|
{ |
85
|
1 |
|
$this->disabled = true; |
86
|
1 |
|
} |
87
|
|
|
|
88
|
1 |
|
public function isDisabled() |
89
|
|
|
{ |
90
|
1 |
|
return $this->disabled; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..