Improvements

Small improvements, such as remove unused imports, unecessaries casts, parentheses, etc.
main
Gabriel Caruso 6 years ago
parent 0c6201de3e
commit 7d9f8e2247
No known key found for this signature in database
GPG Key ID: EA85C7988F5A6877

@ -922,7 +922,7 @@ INITIALIZER;
$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) {
$target = $link->getTarget();
if (!isset($include[$target])) {

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

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

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

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

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

@ -215,7 +215,7 @@ class RuleSetGenerator
}
// 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) {
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
@ -226,7 +226,7 @@ class RuleSetGenerator
}
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));
}
}

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

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

@ -113,7 +113,7 @@ class BinaryInstaller
}
// 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);
}
}

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

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

@ -230,7 +230,7 @@ class RootPackageLoader extends ArrayLoader
{
foreach ($requires as $reqName => $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);
$references[$name] = $match[1];
}

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

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

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

@ -140,7 +140,7 @@ final class TlsHelper
//Convert PEM to DER before SHA1'ing
$start = '-----BEGIN 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);
return sha1($der);

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

Loading…
Cancel
Save