Ver Fonte

Fix some improvements

François Pluchino há 13 anos atrás
pai
commit
03f5eee3fa

+ 3 - 3
src/Composer/Downloader/FileDownloader.php

@@ -94,8 +94,8 @@ abstract class FileDownloader implements DownloaderInterface
             );
         }
 
-        if ($this->io->hasAuthentification($package->getSourceUrl())) {
-            $auth = $this->io->getAuthentification($package->getSourceUrl());
+        if ($this->io->hasAuthorization($package->getSourceUrl())) {
+            $auth = $this->io->getAuthorization($package->getSourceUrl());
             $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
             $params['http'] = array_merge($params['http'], array('header' => "Authorization: Basic $authStr\r\n"));
         }
@@ -171,7 +171,7 @@ abstract class FileDownloader implements DownloaderInterface
     {
         switch ($notificationCode) {
             case STREAM_NOTIFY_AUTH_REQUIRED:
-                throw new \LogicException("Authentification is required");
+                throw new \LogicException("Authorization is required");
                 break;
 
             case STREAM_NOTIFY_FAILURE:

+ 11 - 15
src/Composer/IO/ConsoleIO.php

@@ -28,7 +28,7 @@ class ConsoleIO implements IOInterface
     protected $input;
     protected $output;
     protected $helperSet;
-    protected $authentifications;
+    protected $authorizations = array();
     protected $lastUsername;
     protected $lastPassword;
 
@@ -242,42 +242,38 @@ class ConsoleIO implements IOInterface
     /**
      * {@inheritDoc}
      */
-    public function getAuthentifications()
+    public function getAuthorizations()
     {
-        if (null === $this->authentifications) {
-            $this->authentifications = array();
-        }
-
-        return $this->authentifications;
+        return $this->authorizations;
     }
 
     /**
      * {@inheritDoc}
      */
-    public function hasAuthentification($repositoryName)
+    public function hasAuthorization($repositoryName)
     {
-        $auths = $this->getAuthentifications();
-        return isset($auths[$repositoryName]) ? true : false;
+        $auths = $this->getAuthorizations();
+        return isset($auths[$repositoryName]);
     }
 
     /**
      * {@inheritDoc}
      */
-    public function getAuthentification($repositoryName)
+    public function getAuthorization($repositoryName)
     {
-        $auths = $this->getAuthentifications();
+        $auths = $this->getAuthorizations();
         return isset($auths[$repositoryName]) ? $auths[$repositoryName] : array('username' => null, 'password' => null);
     }
 
     /**
      * {@inheritDoc}
      */
-    public function setAuthentification($repositoryName, $username, $password = null)
+    public function setAuthorization($repositoryName, $username, $password = null)
     {
-        $auths = $this->getAuthentifications();
+        $auths = $this->getAuthorizations();
         $auths[$repositoryName] = array('username' => $username, 'password' => $password);
 
-        $this->authentifications = $auths;
+        $this->authorizations = $auths;
         $this->lastUsername = $username;
         $this->lastPassword = $password;
     }

+ 9 - 11
src/Composer/IO/IOInterface.php

@@ -21,9 +21,7 @@ use Symfony\Component\Console\Helper\HelperSet;
  * @author François Pluchino <francois.pluchino@opendisplay.com>
  */
 interface IOInterface extends OutputInterface
-{
-
-
+{
     /**
      * Is this input means interactive?
      *
@@ -116,20 +114,20 @@ interface IOInterface extends OutputInterface
     function getLastPassword();
 
     /**
-     * Get all authentification informations entered.
+     * Get all authorization informations entered.
      *
-     * @return array The map of authentification
+     * @return array The map of authorization
      */
-    function getAuthentifications();
+    function getAuthorizations();
 
     /**
-     * Verify if the repository has a authentification informations.
+     * Verify if the repository has a authorization informations.
      *
      * @param string $repositoryName The unique name of repository
      *
      * @return boolean
      */
-    function hasAuthentification($repositoryName);
+    function hasAuthorization($repositoryName);
 
     /**
      * Get the username and password of repository.
@@ -138,14 +136,14 @@ interface IOInterface extends OutputInterface
      *
      * @return array The 'username' and 'password'
      */
-    function getAuthentification($repositoryName);
+    function getAuthorization($repositoryName);
 
     /**
-     * Set the authentification informations for the repository.
+     * Set the authorization informations for the repository.
      *
      * @param string $repositoryName The unique name of repository
      * @param string $username       The username
      * @param string $password       The password
      */
-    function setAuthentification($repositoryName, $username, $password = null);
+    function setAuthorization($repositoryName, $username, $password = null);
 }

+ 11 - 11
src/Composer/Repository/Vcs/VcsDriver.php

@@ -15,7 +15,7 @@ namespace Composer\Repository\Vcs;
 use Composer\IO\IOInterface;
 
 /**
- * A driver implementation for driver with authentification interaction.
+ * A driver implementation for driver with authorization interaction.
  *
  * @author François Pluchino <francois.pluchino@opendisplay.com>
  */
@@ -63,11 +63,11 @@ abstract class VcsDriver
     protected function getContents($url)
     {
         $this->contentUrl = $url;
-        $auth = $this->io->getAuthentification($this->url);
+        $auth = $this->io->getAuthorization($this->url);
         $params = array();
 
         // add authorization to curl options
-        if ($this->io->hasAuthentification($this->url)) {
+        if ($this->io->hasAuthorization($this->url)) {
             $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
             $params['http'] = array('header' => "Authorization: Basic $authStr\r\n");
 
@@ -81,7 +81,7 @@ abstract class VcsDriver
 
         $content = @file_get_contents($url, false, $ctx);
 
-        // content get after authentification
+        // content get after authorization
         if (false === $content) {
             $content = $this->content;
             $this->content = null;
@@ -106,36 +106,36 @@ abstract class VcsDriver
         switch ($notificationCode) {
             case STREAM_NOTIFY_AUTH_REQUIRED:
             case STREAM_NOTIFY_FAILURE:
-                // for private repository returning 404 error when the authentification is incorrect
-                $auth = $this->io->getAuthentification($this->url);
+                // for private repository returning 404 error when the authorization is incorrect
+                $auth = $this->io->getAuthorization($this->url);
                 $ps = $this->firstCall && 404 === $messageCode
                         && null === $this->io->getLastUsername()
                         && null === $auth['username'];
 
                 if (404 === $messageCode && !$this->firstCall) {
-                    throw new \LogicException("The '" . $this->contentUrl . "' URL not found");
+                    throw new \RuntimeException("The '" . $this->contentUrl . "' URL not found");
                 }
 
                 if ($this->firstCall) {
                     $this->firstCall = false;
                 }
 
-                // get authentification informations
+                // get authorization informations
                 if (401 === $messageCode || $ps) {
                     if (!$this->io->isInteractive()) {
                         $mess = "The '" . $this->contentUrl . "' URL not found";
 
                         if (401 === $code || $ps) {
-                            $mess = "The '" . $this->contentUrl . "' URL required the authentification.\nYou must be used the interactive console";
+                            $mess = "The '" . $this->contentUrl . "' URL required the authorization.\nYou must be used the interactive console";
                         }
 
-                        throw new \LogicException($mess);
+                        throw new \RuntimeException($mess);
                     }
 
                     $this->io->writeln("Authorization for <info>" . $this->contentUrl . "</info>:");
                     $username = $this->io->ask('    Username: ');
                     $password = $this->io->askAndHideAnswer('    Password: ');
-                    $this->io->setAuthentification($this->url, $username, $password);
+                    $this->io->setAuthorization($this->url, $username, $password);
 
                     $this->content = $this->getContents($this->contentUrl);
                 }