@@ -29,6 +29,10 @@ |
||
| 29 | 29 | |
| 30 | 30 | protected $currentVersion; |
| 31 | 31 | |
| 32 | + /** |
|
| 33 | + * @param string $name |
|
| 34 | + * @param string $gitHubRepository |
|
| 35 | + */ |
|
| 32 | 36 | public function __construct($name = null, $currentVersion = null, $gitHubRepository = null) |
| 33 | 37 | { |
| 34 | 38 | parent::__construct($name); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $this |
| 46 | 46 | ->setName('self-update') |
| 47 | - ->setAliases(array( 'selfupdate' )) |
|
| 47 | + ->setAliases(array('selfupdate')) |
|
| 48 | 48 | ->setDescription('Updates the robo.phar to the latest version.') |
| 49 | 49 | ->setHelp( |
| 50 | 50 | <<<EOT |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'http' => [ |
| 61 | 61 | 'method' => 'GET', |
| 62 | 62 | 'header' => [ |
| 63 | - 'User-Agent: ' . Robo::APPLICATION_NAME . ' (' . $this->gitHubRepository . ')' . ' Self-Update (PHP)' |
|
| 63 | + 'User-Agent: ' . Robo::APPLICATION_NAME . ' (' . $this->gitHubRepository . ')' . ' Self-Update (PHP)' |
|
| 64 | 64 | ] |
| 65 | 65 | ] |
| 66 | 66 | ]; |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | $releases = file_get_contents('https://api.github.com/repos/' . $this->gitHubRepository . '/releases', false, $context); |
| 71 | 71 | $releases = json_decode($releases); |
| 72 | 72 | |
| 73 | - if (! isset($releases[0])) { |
|
| 73 | + if (!isset($releases[0])) { |
|
| 74 | 74 | throw new \Exception('API error - no release found at GitHub repository ' . $this->gitHubRepository); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $version = $releases[0]->tag_name; |
| 78 | 78 | $url = $releases[0]->assets[0]->browser_download_url; |
| 79 | 79 | |
| 80 | - return [ $version, $url ]; |
|
| 80 | + return [$version, $url]; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function isEnabled() |
@@ -97,20 +97,20 @@ discard block |
||
| 97 | 97 | $tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar') . '-temp.phar'; |
| 98 | 98 | |
| 99 | 99 | // check for permissions in local filesystem before start connection process |
| 100 | - if (! is_writable($tempDirectory = dirname($tempFilename))) { |
|
| 100 | + if (!is_writable($tempDirectory = dirname($tempFilename))) { |
|
| 101 | 101 | throw new \Exception( |
| 102 | 102 | $programName . ' update failed: the "' . $tempDirectory . |
| 103 | 103 | '" directory used to download the temp file could not be written' |
| 104 | 104 | ); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if (! is_writable($localFilename)) { |
|
| 107 | + if (!is_writable($localFilename)) { |
|
| 108 | 108 | throw new \Exception( |
| 109 | 109 | $programName . ' update failed: the "' . $localFilename . '" file could not be written (execute with sudo)' |
| 110 | 110 | ); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - list( $latest, $downloadUrl ) = $this->getLatestReleaseFromGithub(); |
|
| 113 | + list($latest, $downloadUrl) = $this->getLatestReleaseFromGithub(); |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | if ($this->currentVersion == $latest) { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->_exit(); |
| 140 | 140 | } catch (\Exception $e) { |
| 141 | 141 | @unlink($tempFilename); |
| 142 | - if (! $e instanceof \UnexpectedValueException && ! $e instanceof \PharException) { |
|
| 142 | + if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { |
|
| 143 | 143 | throw $e; |
| 144 | 144 | } |
| 145 | 145 | $output->writeln('<error>The download is corrupted (' . $e->getMessage() . ').</error>'); |