Эх сурвалжийг харах

Rename LibraryBinariesHandler and reorganize constructor args, refs #5100

Jordi Boggiano 9 жил өмнө
parent
commit
ace88fa986

+ 4 - 6
src/Composer/Installer/LibraryBinariesHandler.php → src/Composer/Installer/BinaryInstaller.php

@@ -20,13 +20,13 @@ use Composer\Util\ProcessExecutor;
 use Composer\Util\Silencer;
 
 /**
- * Package installation manager.
+ * Utility to handle installation of package "bin"/binaries
  *
  * @author Jordi Boggiano <j.boggiano@seld.be>
  * @author Konstantin Kudryashov <ever.zet@gmail.com>
  * @author Helmut Hummel <info@helhum.io>
  */
-class LibraryBinariesHandler
+class BinaryInstaller
 {
     protected $binDir;
     protected $binCompat;
@@ -34,14 +34,12 @@ class LibraryBinariesHandler
     protected $filesystem;
 
     /**
-     * LibraryBinaryHandler constructor.
-     *
+     * @param IOInterface $io
      * @param string $binDir
      * @param string $binCompat
-     * @param IOInterface $io
      * @param Filesystem $filesystem
      */
-    public function __construct($binDir, $binCompat, IOInterface $io, Filesystem $filesystem = null)
+    public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
     {
         $this->binDir = $binDir;
         $this->binCompat = $binCompat;

+ 9 - 9
src/Composer/Installer/LibraryInstaller.php

@@ -35,7 +35,7 @@ class LibraryInstaller implements InstallerInterface
     protected $type;
     protected $filesystem;
     protected $binCompat;
-    protected $libraryBinariesHandler;
+    protected $binaryInstaller;
 
     /**
      * Initializes library installer.
@@ -44,9 +44,9 @@ class LibraryInstaller implements InstallerInterface
      * @param Composer             $composer
      * @param string               $type
      * @param Filesystem           $filesystem
-     * @param LibraryBinariesHandler $libraryBinariesHandler
+     * @param BinaryInstaller      $binaryInstaller
      */
-    public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, LibraryBinariesHandler $libraryBinariesHandler = null)
+    public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
     {
         $this->composer = $composer;
         $this->downloadManager = $composer->getDownloadManager();
@@ -55,7 +55,7 @@ class LibraryInstaller implements InstallerInterface
 
         $this->filesystem = $filesystem ?: new Filesystem();
         $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
-        $this->libraryBinariesHandler = $libraryBinariesHandler ?: new LibraryBinariesHandler(rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->io, $this->filesystem);
+        $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
     }
 
     /**
@@ -84,11 +84,11 @@ class LibraryInstaller implements InstallerInterface
 
         // remove the binaries if it appears the package files are missing
         if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
-            $this->libraryBinariesHandler->removeBinaries($package);
+            $this->binaryInstaller->removeBinaries($package);
         }
 
         $this->installCode($package);
-        $this->libraryBinariesHandler->installBinaries($package, $this->getInstallPath($package));
+        $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package));
         if (!$repo->hasPackage($package)) {
             $repo->addPackage(clone $package);
         }
@@ -105,9 +105,9 @@ class LibraryInstaller implements InstallerInterface
 
         $this->initializeVendorDir();
 
-        $this->libraryBinariesHandler->removeBinaries($initial);
+        $this->binaryInstaller->removeBinaries($initial);
         $this->updateCode($initial, $target);
-        $this->libraryBinariesHandler->installBinaries($target, $this->getInstallPath($target));
+        $this->binaryInstaller->installBinaries($target, $this->getInstallPath($target));
         $repo->removePackage($initial);
         if (!$repo->hasPackage($target)) {
             $repo->addPackage(clone $target);
@@ -124,7 +124,7 @@ class LibraryInstaller implements InstallerInterface
         }
 
         $this->removeCode($package);
-        $this->libraryBinariesHandler->removeBinaries($package);
+        $this->binaryInstaller->removeBinaries($package);
         $repo->removePackage($package);
 
         $downloadPath = $this->getPackageBasePath($package);