From 29312be4df7ff4e429f8ada96497f0cfc1225c77 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 16 Dec 2015 17:47:38 +0000 Subject: [PATCH] Strict typing fixes --- src/Composer/Command/ArchiveCommand.php | 4 ++-- src/Composer/Command/CreateProjectCommand.php | 6 +++--- src/Composer/Command/LicensesCommand.php | 1 + src/Composer/Downloader/VcsDownloader.php | 4 ++++ src/Composer/IO/IOInterface.php | 2 +- src/Composer/Repository/Vcs/GitHubDriver.php | 8 ++++---- src/Composer/Repository/Vcs/VcsDriver.php | 7 +++++++ src/Composer/Util/Git.php | 4 ++++ 8 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index 616976feb..2fea529a6 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -41,8 +41,8 @@ class ArchiveCommand extends Command new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'), new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'), new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'), - new InputOption('dir', false, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'), - new InputOption('file', false, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.' + new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'), + new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.' .' Note that the format will be appended.'), )) ->setHelp(<<installProject( $io, $config, + $input, $input->getArgument('package'), $input->getArgument('directory'), $input->getArgument('version'), @@ -125,12 +126,11 @@ EOT $input->getOption('keep-vcs'), $input->getOption('no-progress'), $input->getOption('no-install'), - $input->getOption('ignore-platform-reqs'), - $input + $input->getOption('ignore-platform-reqs') ); } - public function installProject(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, InputInterface $input) + public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false) { $oldCwd = getcwd(); diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index b542c3fe6..e6e52d481 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -88,6 +88,7 @@ EOT break; case 'json': + $dependencies = array(); foreach ($packages as $package) { $dependencies[$package->getPrettyName()] = array( 'version' => $package->getFullPrettyVersion(), diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index e5eea8296..2d021e3a6 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -23,9 +23,13 @@ use Composer\Util\Filesystem; */ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface { + /** @var IOInterface */ protected $io; + /** @var Config */ protected $config; + /** @var ProcessExecutor */ protected $process; + /** @var Filesystem */ protected $filesystem; public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null) diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index b26700a8c..3165b0d24 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -123,7 +123,7 @@ interface IOInterface * @param string|array $question The question to ask * @param callback $validator A PHP callback * @param null|int $attempts Max number of times to ask before giving up (default of null means infinite) - * @param string $default The default answer if none is given by the user + * @param mixed $default The default answer if none is given by the user * * @throws \Exception When any of the validators return an error * @return mixed diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 517012751..cdd9df89f 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -154,9 +154,9 @@ class GitHubDriver extends VcsDriver while ($notFoundRetries) { try { $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/composer.json?ref='.urlencode($identifier); - $composer = JsonFile::parseJson($this->getContents($resource)); - if (empty($composer['content']) || $composer['encoding'] !== 'base64' || !($composer = base64_decode($composer['content']))) { - throw new \RuntimeException('Could not retrieve composer.json from '.$resource); + $resource = JsonFile::parseJson($this->getContents($resource)); + if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($composer = base64_decode($resource['content']))) { + throw new \RuntimeException('Could not retrieve composer.json for '.$identifier); } break; } catch (TransportException $e) { @@ -167,7 +167,7 @@ class GitHubDriver extends VcsDriver // TODO should be removed when possible // retry fetching if github returns a 404 since they happen randomly $notFoundRetries--; - $composer = false; + $composer = null; } } diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index b03f55684..fd2497dfd 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -26,12 +26,19 @@ use Composer\Util\Filesystem; */ abstract class VcsDriver implements VcsDriverInterface { + /** @var string */ protected $url; + /** @var string */ protected $originUrl; + /** @var array */ protected $repoConfig; + /** @var IOInterface */ protected $io; + /** @var Config */ protected $config; + /** @var ProcessExecutor */ protected $process; + /** @var RemoteFilesystem */ protected $remoteFilesystem; /** diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 6b61ac2d2..aae6eb686 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -20,9 +20,13 @@ use Composer\IO\IOInterface; */ class Git { + /** @var IOInterface */ protected $io; + /** @var Config */ protected $config; + /** @var ProcessExecutor */ protected $process; + /** @var Filesystem */ protected $filesystem; public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)