Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
Small improvements, such as remove unused imports, unecessaries casts, parentheses, etc.
  • Loading branch information
carusogabriel committed Jul 5, 2018
1 parent 0c6201d commit 7d9f8e2
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Composer/Autoload/AutoloadGenerator.php
Expand Up @@ -922,7 +922,7 @@ protected function filterPackageMap(array $packageMap, PackageInterface $mainPac
$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])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Command/ShowCommand.php
Expand Up @@ -383,7 +383,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ($latestPackage && $latestPackage->isAbandoned()) {
$replacement = (is_string($latestPackage->getReplacementPackage()))
$replacement = is_string($latestPackage->getReplacementPackage())
? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
: 'No replacement was suggested';
$packageWarning = sprintf(
Expand Down
1 change: 0 additions & 1 deletion src/Composer/Command/StatusCommand.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/DependencyResolver/GenericRule.php
Expand Up @@ -75,7 +75,7 @@ public function isAssertion()
*/
public function __toString()
{
$result = ($this->isDisabled()) ? 'disabled(' : '(';
$result = $this->isDisabled() ? 'disabled(' : '(';

foreach ($this->literals as $i => $literal) {
if ($i != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/DependencyResolver/Problem.php
Expand Up @@ -247,6 +247,6 @@ protected function getPackageList($packages)
*/
protected function constraintToText($constraint)
{
return ($constraint) ? ' '.$constraint->getPrettyString() : '';
return $constraint ? ' '.$constraint->getPrettyString() : '';
}
}
2 changes: 1 addition & 1 deletion src/Composer/DependencyResolver/Rule2Literals.php
Expand Up @@ -93,7 +93,7 @@ public function isAssertion()
*/
public function __toString()
{
$result = ($this->isDisabled()) ? 'disabled(' : '(';
$result = $this->isDisabled() ? 'disabled(' : '(';

$result .= $this->literal1 . '|' . $this->literal2 . ')';

Expand Down
4 changes: 2 additions & 2 deletions src/Composer/DependencyResolver/RuleSetGenerator.php
Expand Up @@ -215,7 +215,7 @@ protected function addRulesForPackage(PackageInterface $package, $ignorePlatform
}

// 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());
Expand All @@ -226,7 +226,7 @@ protected function addRulesForPackage(PackageInterface $package, $ignorePlatform
}

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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/DependencyResolver/Transaction.php
Expand Up @@ -49,7 +49,7 @@ public function getOperations()
$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;
}

Expand Down
9 changes: 3 additions & 6 deletions src/Composer/Installer.php
Expand Up @@ -251,7 +251,7 @@ public function run()
continue;
}

$replacement = (is_string($package->getReplacementPackage()))
$replacement = is_string($package->getReplacementPackage())
? 'Use ' . $package->getReplacementPackage() . ' instead'
: 'No replacement was suggested';

Expand Down Expand Up @@ -1033,11 +1033,8 @@ private function processDevPackages($localRepo, $pool, $policy, $repositories, $
$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;
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Installer/BinaryInstaller.php
Expand Up @@ -113,7 +113,7 @@ public function removeBinaries(PackageInterface $package)
}

// 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);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Composer/Json/JsonFile.php
Expand Up @@ -281,7 +281,6 @@ public static function parseJson($json, $file = null)
* @param string $json
* @param string $file
* @throws \UnexpectedValueException
* @throws JsonValidationException
* @throws ParsingException
* @return bool true on success
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Json/JsonFormatter.php
Expand Up @@ -88,7 +88,7 @@ public static function format($json, $unescapeUnicode, $unescapeSlashes)
if (':' === $char) {
// Add a space after the : character
$char .= ' ';
} elseif (('}' === $char || ']' === $char)) {
} elseif ('}' === $char || ']' === $char) {
$pos--;
$prevChar = substr($json, $i - 1, 1);

Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Package/Loader/RootPackageLoader.php
Expand Up @@ -230,7 +230,7 @@ private function extractReferences(array $requires, array $references)
{
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];
}
Expand Down
1 change: 0 additions & 1 deletion src/Composer/Package/Loader/ValidatingArrayLoader.php
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Plugin/PluginManager.php
Expand Up @@ -169,7 +169,7 @@ public function registerPackage(PackageInterface $package, $failOnMissingClasses
$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);
}

Expand Down Expand Up @@ -307,7 +307,7 @@ private function lookupInstalledPackage(Pool $pool, Link $link)
{
$packages = $pool->whatProvides($link->getTarget(), $link->getConstraint());

return (!empty($packages)) ? $packages[0] : null;
return !empty($packages) ? $packages[0] : null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Util/Filesystem.php
Expand Up @@ -565,7 +565,7 @@ public function relativeSymlink($target, $link)

chdir($cwd);

return (bool) $result;
return $result;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Util/TlsHelper.php
Expand Up @@ -140,7 +140,7 @@ public static function getCertificateFingerprint($certificate)
//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);
Expand Down
1 change: 0 additions & 1 deletion src/Composer/Util/Url.php
Expand Up @@ -13,7 +13,6 @@
namespace Composer\Util;

use Composer\Config;
use Composer\IO\IOInterface;

/**
* @author Jordi Boggiano <j.boggiano@seld.be>
Expand Down

0 comments on commit 7d9f8e2

Please sign in to comment.