1
0
Fork 0

Merge pull request #7441 from carusogabriel/improvements

Improvements
pull/7421/head
Rob 2018-07-05 14:10:25 +02:00 committed by GitHub
commit f24fcea35b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 18 additions and 25 deletions

View File

@ -922,7 +922,7 @@ INITIALIZER;
$packages[$name] = $package; $packages[$name] = $package;
} }
$add = function (PackageInterface $package) use (&$add, $mainPackage, $packages, &$include) { $add = function (PackageInterface $package) use (&$add, $packages, &$include) {
foreach ($package->getRequires() as $link) { foreach ($package->getRequires() as $link) {
$target = $link->getTarget(); $target = $link->getTarget();
if (!isset($include[$target])) { if (!isset($include[$target])) {

View File

@ -383,7 +383,7 @@ EOT
} }
if ($latestPackage && $latestPackage->isAbandoned()) { if ($latestPackage && $latestPackage->isAbandoned()) {
$replacement = (is_string($latestPackage->getReplacementPackage())) $replacement = is_string($latestPackage->getReplacementPackage())
? 'Use ' . $latestPackage->getReplacementPackage() . ' instead' ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
: 'No replacement was suggested'; : 'No replacement was suggested';
$packageWarning = sprintf( $packageWarning = sprintf(

View File

@ -12,7 +12,6 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Downloader\DownloaderInterface;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;

View File

@ -75,7 +75,7 @@ class GenericRule extends Rule
*/ */
public function __toString() public function __toString()
{ {
$result = ($this->isDisabled()) ? 'disabled(' : '('; $result = $this->isDisabled() ? 'disabled(' : '(';
foreach ($this->literals as $i => $literal) { foreach ($this->literals as $i => $literal) {
if ($i != 0) { if ($i != 0) {

View File

@ -247,6 +247,6 @@ class Problem
*/ */
protected function constraintToText($constraint) protected function constraintToText($constraint)
{ {
return ($constraint) ? ' '.$constraint->getPrettyString() : ''; return $constraint ? ' '.$constraint->getPrettyString() : '';
} }
} }

View File

@ -93,7 +93,7 @@ class Rule2Literals extends Rule
*/ */
public function __toString() public function __toString()
{ {
$result = ($this->isDisabled()) ? 'disabled(' : '('; $result = $this->isDisabled() ? 'disabled(' : '(';
$result .= $this->literal1 . '|' . $this->literal2 . ')'; $result .= $this->literal1 . '|' . $this->literal2 . ')';

View File

@ -215,7 +215,7 @@ class RuleSetGenerator
} }
// check obsoletes and implicit obsoletes of a package // check obsoletes and implicit obsoletes of a package
$isInstalled = (isset($this->installedMap[$package->id])); $isInstalled = isset($this->installedMap[$package->id]);
foreach ($package->getReplaces() as $link) { foreach ($package->getReplaces() as $link) {
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint()); $obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
@ -226,7 +226,7 @@ class RuleSetGenerator
} }
if (!$this->obsoleteImpossibleForAlias($package, $provider)) { if (!$this->obsoleteImpossibleForAlias($package, $provider)) {
$reason = ($isInstalled) ? Rule::RULE_INSTALLED_PACKAGE_OBSOLETES : Rule::RULE_PACKAGE_OBSOLETES; $reason = $isInstalled ? Rule::RULE_INSTALLED_PACKAGE_OBSOLETES : Rule::RULE_PACKAGE_OBSOLETES;
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $provider, $reason, $link)); $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $provider, $reason, $link));
} }
} }

View File

@ -49,7 +49,7 @@ class Transaction
$package = $this->pool->literalToPackage($literal); $package = $this->pool->literalToPackage($literal);
// wanted & installed || !wanted & !installed // wanted & installed || !wanted & !installed
if (($literal > 0) == (isset($this->installedMap[$package->id]))) { if (($literal > 0) == isset($this->installedMap[$package->id])) {
continue; continue;
} }

View File

@ -251,7 +251,7 @@ class Installer
continue; continue;
} }
$replacement = (is_string($package->getReplacementPackage())) $replacement = is_string($package->getReplacementPackage())
? 'Use ' . $package->getReplacementPackage() . ' instead' ? 'Use ' . $package->getReplacementPackage() . ' instead'
: 'No replacement was suggested'; : 'No replacement was suggested';
@ -1033,11 +1033,8 @@ class Installer
$package->setReplaces($newPackage->getReplaces()); $package->setReplaces($newPackage->getReplaces());
} }
if ($task === 'force-updates' && $newPackage && ( if ($task === 'force-updates' && $newPackage && ($newPackage->getSourceReference() && $newPackage->getSourceReference() !== $package->getSourceReference())
(($newPackage->getSourceReference() && $newPackage->getSourceReference() !== $package->getSourceReference()) || ($newPackage->getDistReference() && $newPackage->getDistReference() !== $package->getDistReference())) {
|| ($newPackage->getDistReference() && $newPackage->getDistReference() !== $package->getDistReference())
)
)) {
$operations[] = new UpdateOperation($package, $newPackage); $operations[] = new UpdateOperation($package, $newPackage);
continue; continue;

View File

@ -113,7 +113,7 @@ class BinaryInstaller
} }
// attempt removing the bin dir in case it is left empty // attempt removing the bin dir in case it is left empty
if ((is_dir($this->binDir)) && ($this->filesystem->isDirEmpty($this->binDir))) { if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
Silencer::call('rmdir', $this->binDir); Silencer::call('rmdir', $this->binDir);
} }
} }

View File

@ -281,7 +281,6 @@ class JsonFile
* @param string $json * @param string $json
* @param string $file * @param string $file
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @throws JsonValidationException
* @throws ParsingException * @throws ParsingException
* @return bool true on success * @return bool true on success
*/ */

View File

@ -88,7 +88,7 @@ class JsonFormatter
if (':' === $char) { if (':' === $char) {
// Add a space after the : character // Add a space after the : character
$char .= ' '; $char .= ' ';
} elseif (('}' === $char || ']' === $char)) { } elseif ('}' === $char || ']' === $char) {
$pos--; $pos--;
$prevChar = substr($json, $i - 1, 1); $prevChar = substr($json, $i - 1, 1);

View File

@ -230,7 +230,7 @@ class RootPackageLoader extends ArrayLoader
{ {
foreach ($requires as $reqName => $reqVersion) { foreach ($requires as $reqName => $reqVersion) {
$reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion); $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === ($stabilityName = VersionParser::parseStability($reqVersion))) { if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
$name = strtolower($reqName); $name = strtolower($reqName);
$references[$name] = $match[1]; $references[$name] = $match[1];
} }

View File

@ -12,7 +12,6 @@
namespace Composer\Package\Loader; namespace Composer\Package\Loader;
use Composer\Package;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;

View File

@ -169,7 +169,7 @@ class PluginManager
$generator = $this->composer->getAutoloadGenerator(); $generator = $this->composer->getAutoloadGenerator();
$autoloads = array(); $autoloads = array();
foreach ($autoloadPackages as $autoloadPackage) { foreach ($autoloadPackages as $autoloadPackage) {
$downloadPath = $this->getInstallPath($autoloadPackage, ($globalRepo && $globalRepo->hasPackage($autoloadPackage))); $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
$autoloads[] = array($autoloadPackage, $downloadPath); $autoloads[] = array($autoloadPackage, $downloadPath);
} }
@ -307,7 +307,7 @@ class PluginManager
{ {
$packages = $pool->whatProvides($link->getTarget(), $link->getConstraint()); $packages = $pool->whatProvides($link->getTarget(), $link->getConstraint());
return (!empty($packages)) ? $packages[0] : null; return !empty($packages) ? $packages[0] : null;
} }
/** /**

View File

@ -565,7 +565,7 @@ class Filesystem
chdir($cwd); chdir($cwd);
return (bool) $result; return $result;
} }
/** /**

View File

@ -140,7 +140,7 @@ final class TlsHelper
//Convert PEM to DER before SHA1'ing //Convert PEM to DER before SHA1'ing
$start = '-----BEGIN PUBLIC KEY-----'; $start = '-----BEGIN PUBLIC KEY-----';
$end = '-----END PUBLIC KEY-----'; $end = '-----END PUBLIC KEY-----';
$pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1)); $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
$der = base64_decode($pemtrim); $der = base64_decode($pemtrim);
return sha1($der); return sha1($der);

View File

@ -13,7 +13,6 @@
namespace Composer\Util; namespace Composer\Util;
use Composer\Config; use Composer\Config;
use Composer\IO\IOInterface;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>