| 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 array */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     private $package; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     private $cached = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** @var boolean */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     private $disabled = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     private static $pluginClasses = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'BaseRequest', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         'ConfigFacade', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         'CopyRequest', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         'CurlMulti', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'CurlRemoteFilesystem', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         'FetchException', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         'FetchRequest', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         'FileDownloaderDummy', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         'ParallelizedComposerRepository', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         'Plugin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         'Prefetcher', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         'Share', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 2 |  |     public function activate(Composer $composer, IO\IOInterface $io) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         // @codeCoverageIgnoreStart | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         // guard for self-update problem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         if (__CLASS__ !== 'Hirak\Prestissimo\Plugin') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             return $this->disable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         // @codeCoverageIgnoreEnd | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         // load all classes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 2 |  |         foreach (self::$pluginClasses as $class) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 2 |  |             class_exists(__NAMESPACE__ . '\\' . $class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 2 |  |         $this->io = $io; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 2 |  |         $this->config = $composer->getConfig(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 2 |  |         $this->package = $composer->getPackage(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 2 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 1 |  |     public static function getSubscribedEvents() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 1 |  |             CPlugin\PluginEvents::PRE_FILE_DOWNLOAD => 'onPreFileDownload', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |             Installer\InstallerEvents::PRE_DEPENDENCIES_SOLVING => 'onPreDependenciesSolving', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 1 |  |             Installer\InstallerEvents::POST_DEPENDENCIES_SOLVING => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 1 |  |                 array('onPostDependenciesSolving', PHP_INT_MAX), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * Keep-Alived file downloader | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 82 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |     public function onPreFileDownload(CPlugin\PreFileDownloadEvent $ev) | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |         if ($this->disabled) { | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         $rfs = $ev->getRemoteFilesystem(); | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         $curlrfs = new CurlRemoteFilesystem( | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |             $this->io, | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |             $this->config, | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |             $rfs->getOptions() | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         $ev->setRemoteFilesystem($curlrfs); | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     public function onPreDependenciesSolving(Installer\InstallerEvent $ev) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         if ($this->disabled) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         if ($this->cached) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $repos = $this->package->getRepositories(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         if (isset($repos['packagist']['type']) && $repos['packagist']['type'] === 'composer') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $repo = new ParallelizedComposerRepository($repos['packagist'], $this->io, $this->config); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             $repo->prefetch(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             $this->cached = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * pre-fetch parallel by curl_multi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 1 |  |     public function onPostDependenciesSolving(Installer\InstallerEvent $ev) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 1 |  |         if ($this->disabled) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 1 |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 1 |  |         $prefetcher = new Prefetcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 1 |  |         $prefetcher->fetchAllFromOperations( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 1 |  |             $this->io, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 1 |  |             $this->config, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 1 |  |             $ev->getOperations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 1 |  |     public function disable() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 1 |  |         $this->disabled = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 1 |  |     public function isDisabled() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 1 |  |         return $this->disabled; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 138 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 139 |  |  |  | 
            
                        
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..