diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 888b2a7f2..56ee9f7f4 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -27,6 +27,8 @@ use Symfony\Component\Console\Command\Command; /** * Base class for Composer commands * + * @method Application getApplication() + * * @author Ryan Weaver * @author Konstantin Kudryashov */ @@ -46,7 +48,7 @@ abstract class BaseCommand extends Command * @param bool $required * @param bool|null $disablePlugins * @throws \RuntimeException - * @return Composer + * @return Composer|null */ public function getComposer($required = true, $disablePlugins = null) { @@ -173,7 +175,7 @@ abstract class BaseCommand extends Command if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) { $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs')); - $preferDist = $input->getOption('prefer-dist'); + $preferDist = (bool) $input->getOption('prefer-dist'); } return array($preferSource, $preferDist); diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 89ba495cf..3970d915d 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -226,7 +226,7 @@ EOT } $settingKey = $input->getArgument('setting-key'); - if (!$settingKey) { + if (!$settingKey || !is_string($settingKey)) { return 0; } diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 481d58060..c123e7003 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -602,20 +602,6 @@ EOT $text .= "Install either of them or recompile php without --disable-iconv"; break; - case 'unicode': - $text = PHP_EOL."The detect_unicode setting must be disabled.".PHP_EOL; - $text .= "Add the following to the end of your `php.ini`:".PHP_EOL; - $text .= " detect_unicode = Off"; - $displayIniMessage = true; - break; - - case 'suhosin': - $text = PHP_EOL."The suhosin.executor.include.whitelist setting is incorrect.".PHP_EOL; - $text .= "Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):".PHP_EOL; - $text .= " suhosin.executor.include.whitelist = phar ".$current; - $displayIniMessage = true; - break; - case 'php': $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher."; break; @@ -713,7 +699,7 @@ EOT /** * Check if allow_url_fopen is ON * - * @return bool|string + * @return true|string */ private function checkConnectivity() { diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 5cb3fa860..a5a2cd780 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -823,10 +823,10 @@ EOT /** * Display a package tree * - * @param PackageInterface|string $package - * @param array $packagesInTree - * @param string $previousTreeBar - * @param int $level + * @param array|string $package + * @param array $packagesInTree + * @param string $previousTreeBar + * @param int $level */ protected function displayTree( $package, @@ -835,7 +835,7 @@ EOT $level = 1 ) { $previousTreeBar = str_replace('├', '│', $previousTreeBar); - if (isset($package['requires'])) { + if (is_array($package) && isset($package['requires'])) { $requires = $package['requires']; $treeBar = $previousTreeBar . ' ├'; $i = 0; @@ -968,7 +968,7 @@ EOT * @param string $phpVersion * @param bool $minorOnly * - * @return PackageInterface|null + * @return PackageInterface|false */ private function findLatestPackage(PackageInterface $package, Composer $composer, $phpVersion, $minorOnly = false) { diff --git a/src/Composer/Command/SuggestsCommand.php b/src/Composer/Command/SuggestsCommand.php index 225725e12..1c1f23f93 100644 --- a/src/Composer/Command/SuggestsCommand.php +++ b/src/Composer/Command/SuggestsCommand.php @@ -43,6 +43,9 @@ EOT ; } + /** + * {@inheritDoc} + */ protected function execute(InputInterface $input, OutputInterface $output) { $lock = $this->getComposer()->getLocker()->getLockData(); @@ -117,7 +120,7 @@ EOT $io->write(sprintf('%s', $suggestion)); } - return; + return null; } // Grouped by package diff --git a/src/Composer/Config/ConfigSourceInterface.php b/src/Composer/Config/ConfigSourceInterface.php index 0d56fc0ed..a00e989bb 100644 --- a/src/Composer/Config/ConfigSourceInterface.php +++ b/src/Composer/Config/ConfigSourceInterface.php @@ -39,7 +39,7 @@ interface ConfigSourceInterface * Add a config setting * * @param string $name Name - * @param string $value Value + * @param string|array $value Value */ public function addConfigSetting($name, $value); diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index 15d40d200..e22bbb1e5 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/src/Composer/Config/JsonConfigSource.php @@ -259,7 +259,7 @@ class JsonConfigSource implements ConfigSourceInterface * * @param array $array * @param mixed $value - * @return array + * @return int */ private function arrayUnshiftRef(&$array, &$value) { diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 0bfee80f3..64a32b46f 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -284,7 +284,7 @@ class Application extends BaseApplication return $result; } catch (ScriptExecutionException $e) { - return $e->getCode(); + return (int) $e->getCode(); } catch (\Exception $e) { $this->hintCommonErrors($e); restore_error_handler(); diff --git a/src/Composer/DependencyResolver/GenericRule.php b/src/Composer/DependencyResolver/GenericRule.php index df8a2a003..eb753067e 100644 --- a/src/Composer/DependencyResolver/GenericRule.php +++ b/src/Composer/DependencyResolver/GenericRule.php @@ -23,10 +23,10 @@ class GenericRule extends Rule protected $literals; /** - * @param array $literals - * @param int $reason A RULE_* constant describing the reason for generating this rule - * @param Link|PackageInterface $reasonData - * @param array $job The job this rule was created from + * @param array $literals + * @param int|null $reason A RULE_* constant describing the reason for generating this rule + * @param Link|PackageInterface|int|null $reasonData + * @param array $job The job this rule was created from */ public function __construct(array $literals, $reason, $reasonData, $job = null) { diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index 9eb3dc0d0..42444cc91 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -176,12 +176,12 @@ class PoolBuilder if (!isset($this->loadedNames[$require])) { $loadNames[$require] = null; } - if ($link->getConstraint()) { + if ($linkConstraint = $link->getConstraint()) { if (!array_key_exists($require, $this->nameConstraints)) { - $this->nameConstraints[$require] = new MultiConstraint(array($link->getConstraint()), false); + $this->nameConstraints[$require] = new MultiConstraint(array($linkConstraint), false); } elseif ($this->nameConstraints[$require]) { // TODO addConstraint function? - $this->nameConstraints[$require] = new MultiConstraint(array_merge(array($link->getConstraint()), $this->nameConstraints[$require]->getConstraints()), false); + $this->nameConstraints[$require] = new MultiConstraint(array_merge(array($linkConstraint), $this->nameConstraints[$require]->getConstraints()), false); } } else { $this->nameConstraints[$require] = null; diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 271c7261f..98b07405a 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -180,7 +180,7 @@ class Problem * Store a reason descriptor but ignore duplicates * * @param string $id A canonical identifier for the reason - * @param string $reason The reason descriptor + * @param string|array $reason The reason descriptor */ protected function addReason($id, $reason) { diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 2188d99ce..821928382 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -13,6 +13,7 @@ namespace Composer\DependencyResolver; use Composer\IO\IOInterface; +use Composer\Package\PackageInterface; use Composer\Repository\RepositoryInterface; use Composer\Repository\PlatformRepository; use Composer\Repository\RepositorySet; @@ -44,7 +45,7 @@ class Solver protected $watchGraph; /** @var Decisions */ protected $decisions; - /** @var int[] */ + /** @var PackageInterface[] */ protected $installedMap; /** @var int */ @@ -691,7 +692,7 @@ class Solver /** * @todo this makes $disableRules always false; determine the rationale and possibly remove dead code? */ - $disableRules = array(); + $disableRules = false; $level = 1; $systemLevel = $level + 1; diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 0b1ddb5a6..a23c167b5 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -294,9 +294,7 @@ class DownloadManager // if downloader type changed, or update failed and user asks for reinstall, // we wipe the dir and do a new install instead of updating it - if ($initialDownloader) { - $initialDownloader->remove($initial, $targetDir); - } + $initialDownloader->remove($initial, $targetDir); $this->install($target, $targetDir); } diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 96e47cb22..f698981fe 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -362,7 +362,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface ) { $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference)); if (0 === $this->process->execute($command, $output, $path)) { - return; + return null; } } @@ -380,14 +380,14 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface ) { $command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference)); if (0 === $this->process->execute($command, $output, $path)) { - return; + return null; } } } $command = sprintf($template, ProcessExecutor::escape($gitRef)); if (0 === $this->process->execute($command, $output, $path)) { - return; + return null; } // reference was not found (prints "fatal: reference is not a tree: $ref") diff --git a/src/Composer/Downloader/PerforceDownloader.php b/src/Composer/Downloader/PerforceDownloader.php index a7dc013b3..0427ec8c8 100644 --- a/src/Composer/Downloader/PerforceDownloader.php +++ b/src/Composer/Downloader/PerforceDownloader.php @@ -88,7 +88,7 @@ class PerforceDownloader extends VcsDownloader { $this->io->writeError('Perforce driver does not check for local changes before overriding', true); - return; + return null; } /** diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index c24660659..05e34dda1 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -199,6 +199,7 @@ class EventDispatcher } try { + /** @var InstallerEvent $event */ $return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags)); } catch (ScriptExecutionException $e) { $this->io->writeError(sprintf('Script %s was called via %s', $callable, $event->getName()), true, IOInterface::QUIET); @@ -499,7 +500,7 @@ class EventDispatcher * * @param Event $event * @throws \RuntimeException - * @return number + * @return int */ protected function pushEvent(Event $event) { diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index b2fd4efab..383337aa6 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -413,7 +413,7 @@ class Factory /** * @param IOInterface $io IO instance * @param bool $disablePlugins Whether plugins should not be loaded - * @return Composer + * @return Composer|null */ public static function createGlobal(IOInterface $io, $disablePlugins = false) { diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index 46302088f..95f891c57 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -108,7 +108,7 @@ interface IOInterface extends LoggerInterface * @param string $default The default answer if none is given by the user * * @throws \RuntimeException If there is no data to read in the input stream - * @return string The user answer + * @return string|null The user answer */ public function ask($question, $default = null); @@ -146,7 +146,7 @@ interface IOInterface extends LoggerInterface * * @param string $question The question to ask * - * @return string The answer + * @return string|null The answer */ public function askAndHideAnswer($question); @@ -161,7 +161,7 @@ interface IOInterface extends LoggerInterface * @param bool $multiselect Select more than one value separated by comma * * @throws \InvalidArgumentException - * @return int|string|array The selected value or values (the key of the choices array) + * @return int|string|array|bool The selected value or values (the key of the choices array) */ public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false); diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 19c0015d6..fc877f18e 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -959,7 +959,7 @@ class Installer * @param RepositoryInterface $lockedRepository * @param string $task * @param array|null $operations - * @return array + * @return array|null */ private function processDevPackages($localRepo, Pool $pool, $policy, $repositories, $installedRepo, $lockedRepository, $task, array $operations = null) { diff --git a/src/Composer/Installer/InstallerInterface.php b/src/Composer/Installer/InstallerInterface.php index e00877ed9..310c5fcfc 100644 --- a/src/Composer/Installer/InstallerInterface.php +++ b/src/Composer/Installer/InstallerInterface.php @@ -48,7 +48,7 @@ interface InstallerInterface * * @param PackageInterface $package package instance * @param PackageInterface $prevPackage previous package instance in case of an update - * @return PromiseInterface + * @return PromiseInterface|null */ public function download(PackageInterface $package, PackageInterface $prevPackage = null); diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 4c2f45601..a89553b1b 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -43,7 +43,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface * * @param IOInterface $io * @param Composer $composer - * @param string $type + * @param string|null $type * @param Filesystem $filesystem * @param BinaryInstaller $binaryInstaller */ diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index f2f5be707..9630e7ef0 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -239,7 +239,7 @@ abstract class BasePackage implements PackageInterface * Build a regexp from a package name, expanding * globs as required * * @param string $whiteListedPattern - * @param bool $wrap Wrap the cleaned string by the given string + * @param string $wrap Wrap the cleaned string by the given string * @return string */ public static function packageNameToRegexp($whiteListedPattern, $wrap = '{^%s$}i') diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index 73d2ade41..30488e89f 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -76,7 +76,7 @@ interface PackageInterface /** * Returns the package targetDir property * - * @return string The package targetDir + * @return string|null The package targetDir */ public function getTargetDir(); diff --git a/src/Composer/Package/Version/VersionSelector.php b/src/Composer/Package/Version/VersionSelector.php index d99780ab1..a8b4ae17b 100644 --- a/src/Composer/Package/Version/VersionSelector.php +++ b/src/Composer/Package/Version/VersionSelector.php @@ -45,7 +45,7 @@ class VersionSelector * @param string $targetPackageVersion * @param string $targetPhpVersion * @param string $preferredStability - * @return PackageInterface|bool + * @return PackageInterface|false */ public function findBestCandidate($packageName, $targetPackageVersion = null, $targetPhpVersion = null, $preferredStability = 'stable') { diff --git a/src/Composer/Repository/Pear/BaseChannelReader.php b/src/Composer/Repository/Pear/BaseChannelReader.php index b778bf08b..9b9acf2f2 100644 --- a/src/Composer/Repository/Pear/BaseChannelReader.php +++ b/src/Composer/Repository/Pear/BaseChannelReader.php @@ -47,7 +47,7 @@ abstract class BaseChannelReader * @param string $origin server * @param string $path relative path to content * @throws \UnexpectedValueException - * @return \SimpleXMLElement + * @return string */ protected function requestContent($origin, $path) { diff --git a/src/Composer/Repository/Pear/ChannelRest10Reader.php b/src/Composer/Repository/Pear/ChannelRest10Reader.php index 93969043a..9d14b71ea 100644 --- a/src/Composer/Repository/Pear/ChannelRest10Reader.php +++ b/src/Composer/Repository/Pear/ChannelRest10Reader.php @@ -150,7 +150,7 @@ class ChannelRest10Reader extends BaseChannelReader * @param string $baseUrl * @param string $packageName * @param string $version - * @return DependencyInfo[] + * @return DependencyInfo */ private function readPackageReleaseDependencies($baseUrl, $packageName, $version) { diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 1bb22c0ed..5cffb6233 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -97,7 +97,7 @@ class PearRepository extends ArrayRepository implements ConfigurableRepositoryIn * * @param ChannelInfo $channelInfo * @param SemverVersionParser $versionParser - * @return CompletePackage + * @return CompletePackage[] */ private function buildComposerPackages(ChannelInfo $channelInfo, SemverVersionParser $versionParser) { diff --git a/src/Composer/Repository/Vcs/VcsDriverInterface.php b/src/Composer/Repository/Vcs/VcsDriverInterface.php index 5e3bcec68..e59bcf647 100644 --- a/src/Composer/Repository/Vcs/VcsDriverInterface.php +++ b/src/Composer/Repository/Vcs/VcsDriverInterface.php @@ -38,7 +38,7 @@ interface VcsDriverInterface * * @param string $file * @param string $identifier - * @return string + * @return string|null */ public function getFileContent($file, $identifier); @@ -46,7 +46,7 @@ interface VcsDriverInterface * Get the changedate for $identifier. * * @param string $identifier - * @return \DateTime + * @return \DateTime|null */ public function getChangeDate($identifier); @@ -73,7 +73,7 @@ interface VcsDriverInterface /** * @param string $identifier Any identifier to a specific branch/tag/commit - * @return array With type, url reference and shasum keys. + * @return array|null With type, url reference and shasum keys. */ public function getDist($identifier); diff --git a/src/Composer/Util/AuthHelper.php b/src/Composer/Util/AuthHelper.php index 3679b93da..2868d3346 100644 --- a/src/Composer/Util/AuthHelper.php +++ b/src/Composer/Util/AuthHelper.php @@ -73,7 +73,7 @@ class AuthHelper * @param string|null $reason a message/description explaining why this was called * @param string $warning an authentication warning returned by the server as {"warning": ".."}, if present * @param string[] $headers - * @return array containing retry (bool) and storeAuth (string|bool) keys, if retry is true the request should be + * @return array|null containing retry (bool) and storeAuth (string|bool) keys, if retry is true the request should be * retried, if storeAuth is true then on a successful retry the authentication should be persisted to auth.json */ public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $warning = null, $headers = array()) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 805eda14b..2d73016c6 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -292,6 +292,7 @@ class Filesystem $this->ensureDirectoryExists($target); $result = true; + /** @var RecursiveDirectoryIterator $ri */ foreach ($ri as $file) { $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName(); if ($file->isDir()) { diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index 68e11a4a4..5a5ec14b2 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -117,7 +117,7 @@ class HttpDownloader /** * Merges new options * - * @return array $options + * @return void */ public function setOptions(array $options) { diff --git a/src/Composer/Util/Loop.php b/src/Composer/Util/Loop.php index c50cf4b02..dfaa2ac53 100644 --- a/src/Composer/Util/Loop.php +++ b/src/Composer/Util/Loop.php @@ -29,6 +29,7 @@ class Loop public function wait(array $promises) { + /** @var \Exception|null */ $uncaught = null; \React\Promise\all($promises)->then( diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index e2c50472c..07eccc791 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -398,7 +398,7 @@ class RemoteFilesystem // fail 4xx and 5xx responses and capture the response if ($statusCode && $statusCode >= 400 && $statusCode <= 599) { if (!$this->retry) { - if ($this->progress && !$this->retry && !$isRedirect) { + if ($this->progress && !$isRedirect) { $this->io->overwriteError("Downloading (failed)", false); } diff --git a/src/Composer/Util/Svn.php b/src/Composer/Util/Svn.php index 58114ac93..be1a81c91 100644 --- a/src/Composer/Util/Svn.php +++ b/src/Composer/Util/Svn.php @@ -304,7 +304,7 @@ class Svn $this->createAuthFromUrl(); } - return $this->hasAuth; + return (bool) $this->hasAuth; } /**