Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Symfony/Installer/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@
*/
class AboutCommand extends Command
{
/**
* @var string The current version of the Symfony installer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not needed as the type can be inferred from the constructor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right ... but let's leave it for consistency sake.

*/
private $appVersion;

/**
* Constructor.
*
* @param string $appVersion The current version of the Symfony installer
*/
public function __construct($appVersion)
{
parent::__construct();

$this->appVersion = $appVersion;
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand All @@ -39,6 +50,9 @@ protected function configure()
;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$commandHelp = <<<COMMAND_HELP
Expand Down Expand Up @@ -99,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
/**
* Returns the executed command.
*
* @return string
* @return string The executed command
*/
private function getExecutedCommand()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Installer/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Application extends ConsoleApplication
{
const VERSIONS_URL = 'https://get.symfony.com/symfony.version';

/**
* {@inheritdoc}
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
return parent::doRun($input, $output);
Expand Down
19 changes: 17 additions & 2 deletions src/Symfony/Installer/DemoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
class DemoCommand extends DownloadCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand All @@ -32,6 +35,9 @@ protected function configure()
;
}

/**
* {@inheritdoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);
Expand All @@ -56,6 +62,9 @@ protected function initialize(InputInterface $input, OutputInterface $output)
}
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
Expand Down Expand Up @@ -94,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
* Removes all the temporary files and directories created to
* download the demo application.
*
* @return NewCommand
* @return $this
*/
private function cleanUp()
{
Expand All @@ -107,7 +116,7 @@ private function cleanUp()
* It displays the message with the result of installing the Symfony Demo
* application and provides some pointers to the user.
*
* @return DemoCommand
* @return $this
*/
private function displayInstallationResult()
{
Expand Down Expand Up @@ -145,11 +154,17 @@ private function displayInstallationResult()
return $this;
}

/**
* {@inheritdoc}
*/
protected function getDownloadedApplicationType()
{
return 'the Symfony Demo Application';
}

/**
* {@inheritdoc}
*/
protected function getRemoteFileUrl()
{
return 'http://symfony.com/download?v=Symfony_Demo';
Expand Down
65 changes: 44 additions & 21 deletions src/Symfony/Installer/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,53 +38,58 @@
abstract class DownloadCommand extends Command
{
/**
* @var Filesystem
* @var Filesystem To dump content to a file
*/
protected $fs;

/**
* @var OutputInterface
* @var OutputInterface To output content
*/
protected $output;

/**
* @var string
* @var string The project name
*/
protected $projectName;

/**
* @var string
* @var string The project dir
*/
protected $projectDir;

/**
* @var string
* @var string The version to install
*/
protected $version = 'latest';

/**
* @var string
* @var string The path to the downloaded file
*/
protected $downloadedFilePath;

/**
* @var array
* @var array The requirement errors
*/
protected $requirementsErrors = array();

/**
* Returns the type of the downloaded application in a human readable format.
* It's mainly used to display readable error messages.
*
* @return string
* @return string The type of the downloaded application in a human readable format
*/
abstract protected function getDownloadedApplicationType();

/**
* Returns the absolute URL of the remote file downloaded by the command.
*
* @return string The absolute URL of the remote file downloaded by the command
*/
abstract protected function getRemoteFileUrl();

/**
* {@inheritdoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
Expand All @@ -100,7 +105,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
*
* @return $this
*
* @throws \RuntimeException if the Symfony archive could not be downloaded
* @throws \RuntimeException If the Symfony archive could not be downloaded
*/
protected function download()
{
Expand Down Expand Up @@ -189,6 +194,13 @@ protected function download()
return $this;
}

/**
* Checks the project name.
*
* @return $this
*
* @throws \RuntimeException If there is already a projet in the specified directory
*/
protected function checkProjectName()
{
if (is_dir($this->projectDir) && !$this->isEmptyDirectory($this->projectDir)) {
Expand All @@ -206,7 +218,9 @@ protected function checkProjectName()
* Returns the Guzzle client configured according to the system environment
* (e.g. it takes into account whether it should use a proxy server or not).
*
* @return Client
* @return Client The configured Guzzle client
*
* @throws \RuntimeException If the php-curl is not installed or the allow_url_fopen ini setting is not set
*/
protected function getGuzzleClient()
{
Expand Down Expand Up @@ -234,9 +248,9 @@ protected function getGuzzleClient()
* Extracts the compressed Symfony file (ZIP or TGZ) using the
* native operating system commands if available or PHP code otherwise.
*
* @return DownloadCommand
* @return $this
*
* @throws \RuntimeException if the downloaded archive could not be extracted
* @throws \RuntimeException If the downloaded archive could not be extracted
*/
protected function extract()
{
Expand Down Expand Up @@ -341,7 +355,7 @@ protected function createGitIgnore()
* Returns the full Symfony version number of the project by getting
* it from the composer.lock file.
*
* @return string
* @return string The installed Symfony version
*/
protected function getInstalledSymfonyVersion()
{
Expand All @@ -360,6 +374,10 @@ protected function getInstalledSymfonyVersion()

/**
* Checks if the installer has enough permissions to create the project.
*
* @return $this
*
* @throws IOException If the installer does not have enough permissions to write to the project parent directory
*/
protected function checkPermissions()
{
Expand Down Expand Up @@ -399,7 +417,7 @@ protected function formatSize($bytes)
* @param \Requirement $requirement The Symfony requirements
* @param int $lineSize The maximum line length
*
* @return string
* @return string The formatted error message
*/
protected function getErrorMessage(\Requirement $requirement, $lineSize = 70)
{
Expand All @@ -416,7 +434,7 @@ protected function getErrorMessage(\Requirement $requirement, $lineSize = 70)
/**
* Generates a good random value for Symfony's 'secret' option.
*
* @return string
* @return string The randomly generated secret
*/
protected function generateRandomSecret()
{
Expand All @@ -431,7 +449,7 @@ protected function generateRandomSecret()
* Returns the executed command with all its arguments
* (e.g. "symfony new blog 2.8.1").
*
* @return string
* @return string The executed command with all its arguments
*/
protected function getExecutedCommand()
{
Expand All @@ -458,7 +476,7 @@ protected function getExecutedCommand()
*
* @param string $dir the path of the directory to check
*
* @return bool
* @return bool Whether the given directory is empty
*/
protected function isEmptyDirectory($dir)
{
Expand All @@ -470,7 +488,7 @@ protected function isEmptyDirectory($dir)
/**
* Checks that the asked version is in the 3.x branch.
*
* @return bool
* @return bool Wheter is Symfony3
*/
protected function isSymfony3()
{
Expand Down Expand Up @@ -502,7 +520,7 @@ protected function checkInstallerVersion()
}

/**
* @return boolean Whether the installed version is the latest one
* @return bool Whether the installed version is the latest one
*/
protected function isInstallerUpdated()
{
Expand All @@ -515,9 +533,9 @@ protected function isInstallerUpdated()
/**
* Returns the contents obtained by making a GET request to the given URL.
*
* @param string $url
* @param string $url The URL to get the contents from
*
* @return string
* @return string The obtained contents of $url
*/
protected function getUrlContents($url)
{
Expand All @@ -526,6 +544,11 @@ protected function getUrlContents($url)
return $client->get($url)->getBody()->getContents();
}

/**
* Enables the signal handler.
*
* @throws AbortException If the execution has been aborted with SIGINT signal.
*/
private function enableSignalHandler()
{
if (!function_exists('pcntl_signal')) {
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Installer/Exception/AbortException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Symfony\Installer\Exception;

/**
* This exception is thrown when the execution is aborted with the SIGINT signal.
*
* @author Grégoire Pineau <[email protected]>
*/
class AbortException extends \RuntimeException
{
}
Loading