1
0
Fork 0

Merge pull request #4502 from alcohol/cs-fixes

php-cs-fixer
pull/4504/head
Jordi Boggiano 2015-10-13 11:30:45 +01:00
commit 2a8ea0bcc9
11 changed files with 201 additions and 40 deletions

18
.php_cs
View File

@ -1,5 +1,15 @@
<?php <?php
$header = <<<EOF
This file is part of Composer.
(c) Nils Adermann <naderman@naderman.de>
Jordi Boggiano <j.boggiano@seld.be>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;
$finder = Symfony\CS\Finder\DefaultFinder::create() $finder = Symfony\CS\Finder\DefaultFinder::create()
->files() ->files()
->name('*.php') ->name('*.php')
@ -15,9 +25,14 @@ return Symfony\CS\Config\Config::create()
'@PSR2' => true, '@PSR2' => true,
'duplicate_semicolon' => true, 'duplicate_semicolon' => true,
'extra_empty_lines' => true, 'extra_empty_lines' => true,
'header_comment' => array('header' => $header),
'include' => true, 'include' => true,
'long_array_syntax' => true,
'method_separation' => true,
'multiline_array_trailing_comma' => true, 'multiline_array_trailing_comma' => true,
'namespace_no_leading_whitespace' => true, 'namespace_no_leading_whitespace' => true,
'no_blank_lines_after_class_opening' => true,
'no_empty_lines_after_phpdocs' => true,
'object_operator' => true, 'object_operator' => true,
'operators_spaces' => true, 'operators_spaces' => true,
'phpdoc_align' => true, 'phpdoc_align' => true,
@ -30,7 +45,10 @@ return Symfony\CS\Config\Config::create()
'phpdoc_type_to_var' => true, 'phpdoc_type_to_var' => true,
'psr0' => true, 'psr0' => true,
'return' => true, 'return' => true,
'remove_leading_slash_use' => true,
'remove_lines_between_uses' => true,
'single_array_no_trailing_comma' => true, 'single_array_no_trailing_comma' => true,
'single_blank_line_before_namespace' => true,
'spaces_cast' => true, 'spaces_cast' => true,
'standardize_not_equal' => true, 'standardize_not_equal' => true,
'ternary_spaces' => true, 'ternary_spaces' => true,

View File

@ -1,14 +1,19 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* /*
* This file is copied from the Symfony package. * This file is copied from the Symfony package.
* *
* (c) Fabien Potencier <fabien@symfony.com> * (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT
*/ */
namespace Composer\Autoload; namespace Composer\Autoload;

View File

@ -20,6 +20,8 @@ use Composer\Package\PackageInterface;
interface PolicyInterface interface PolicyInterface
{ {
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator); public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
public function findUpdatePackages(Pool $pool, array $installedMap, PackageInterface $package); public function findUpdatePackages(Pool $pool, array $installedMap, PackageInterface $package);
public function selectPreferredPackages(Pool $pool, array $installedMap, array $literals); public function selectPreferredPackages(Pool $pool, array $installedMap, array $literals);
} }

View File

@ -23,25 +23,44 @@ class Solver
const BRANCH_LITERALS = 0; const BRANCH_LITERALS = 0;
const BRANCH_LEVEL = 1; const BRANCH_LEVEL = 1;
/** @var PolicyInterface */
protected $policy; protected $policy;
/** @var Pool */
protected $pool; protected $pool;
/** @var RepositoryInterface */
protected $installed; protected $installed;
/** @var Ruleset */
protected $rules; protected $rules;
/** @var RuleSetGenerator */
protected $ruleSetGenerator; protected $ruleSetGenerator;
protected $updateAll; /** @var array */
protected $jobs;
protected $addedMap = array(); /** @var int[] */
protected $updateMap = array(); protected $updateMap = array();
/** @var RuleWatchGraph */
protected $watchGraph; protected $watchGraph;
/** @var Decisions */
protected $decisions; protected $decisions;
/** @var int[] */
protected $installedMap; protected $installedMap;
/** @var int */
protected $propagateIndex; protected $propagateIndex;
/** @var array[] */
protected $branches = array(); protected $branches = array();
/** @var Problem[] */
protected $problems = array(); protected $problems = array();
/** @var array */
protected $learnedPool = array(); protected $learnedPool = array();
/** @var array */
protected $learnedWhy = array(); protected $learnedWhy = array();
/**
* @param PolicyInterface $policy
* @param Pool $pool
* @param RepositoryInterface $installed
*/
public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed) public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed)
{ {
$this->policy = $policy; $this->policy = $policy;
@ -50,12 +69,16 @@ class Solver
$this->ruleSetGenerator = new RuleSetGenerator($policy, $pool); $this->ruleSetGenerator = new RuleSetGenerator($policy, $pool);
} }
/**
* @return int
*/
public function getRuleSetSize() public function getRuleSetSize()
{ {
return count($this->rules); return count($this->rules);
} }
// aka solver_makeruledecisions // aka solver_makeruledecisions
private function makeAssertionRuleDecisions() private function makeAssertionRuleDecisions()
{ {
$decisionStart = count($this->decisions) - 1; $decisionStart = count($this->decisions) - 1;
@ -135,6 +158,9 @@ class Solver
} }
} }
/**
* @param bool $ignorePlatformReqs
*/
protected function checkForRootRequireProblems($ignorePlatformReqs) protected function checkForRootRequireProblems($ignorePlatformReqs)
{ {
foreach ($this->jobs as $job) { foreach ($this->jobs as $job) {
@ -169,6 +195,11 @@ class Solver
} }
} }
/**
* @param Request $request
* @param bool $ignorePlatformReqs
* @return array
*/
public function solve(Request $request, $ignorePlatformReqs = false) public function solve(Request $request, $ignorePlatformReqs = false)
{ {
$this->jobs = $request->getJobs(); $this->jobs = $request->getJobs();
@ -243,6 +274,8 @@ class Solver
/** /**
* Reverts a decision at the given level. * Reverts a decision at the given level.
*
* @param int $level
*/ */
private function revert($level) private function revert($level)
{ {
@ -268,8 +301,7 @@ class Solver
} }
} }
/**------------------------------------------------------------------- /**
*
* setpropagatelearn * setpropagatelearn
* *
* add free decision (a positive literal) to decision queue * add free decision (a positive literal) to decision queue
@ -282,6 +314,11 @@ class Solver
* *
* returns the new solver level or 0 if unsolvable * returns the new solver level or 0 if unsolvable
* *
* @param int $level
* @param string|int $literal
* @param bool $disableRules
* @param Rule $rule
* @return int
*/ */
private function setPropagateLearn($level, $literal, $disableRules, Rule $rule) private function setPropagateLearn($level, $literal, $disableRules, Rule $rule)
{ {
@ -331,6 +368,13 @@ class Solver
return $level; return $level;
} }
/**
* @param int $level
* @param array $decisionQueue
* @param bool $disableRules
* @param Rule $rule
* @return int
*/
private function selectAndInstall($level, array $decisionQueue, $disableRules, Rule $rule) private function selectAndInstall($level, array $decisionQueue, $disableRules, Rule $rule)
{ {
// choose best package to install from decisionQueue // choose best package to install from decisionQueue
@ -346,7 +390,12 @@ class Solver
return $this->setPropagateLearn($level, $selectedLiteral, $disableRules, $rule); return $this->setPropagateLearn($level, $selectedLiteral, $disableRules, $rule);
} }
protected function analyze($level, $rule) /**
* @param int $level
* @param Rule $rule
* @return array
*/
protected function analyze($level, Rule $rule)
{ {
$analyzedRule = $rule; $analyzedRule = $rule;
$ruleLevel = 1; $ruleLevel = 1;
@ -452,7 +501,11 @@ class Solver
return array($learnedLiterals[0], $ruleLevel, $newRule, $why); return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
} }
private function analyzeUnsolvableRule($problem, $conflictRule) /**
* @param Problem $problem
* @param Rule $conflictRule
*/
private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule)
{ {
$why = spl_object_hash($conflictRule); $why = spl_object_hash($conflictRule);
@ -476,7 +529,12 @@ class Solver
$problem->addRule($conflictRule); $problem->addRule($conflictRule);
} }
private function analyzeUnsolvable($conflictRule, $disableRules) /**
* @param Rule $conflictRule
* @param bool $disableRules
* @return int
*/
private function analyzeUnsolvable(Rule $conflictRule, $disableRules)
{ {
$problem = new Problem($this->pool); $problem = new Problem($this->pool);
$problem->addRule($conflictRule); $problem->addRule($conflictRule);
@ -533,7 +591,10 @@ class Solver
return 0; return 0;
} }
private function disableProblem($why) /**
* @param Rule $why
*/
private function disableProblem(Rule $why)
{ {
$job = $why->getJob(); $job = $why->getJob();
@ -545,6 +606,7 @@ class Solver
// disable all rules of this job // disable all rules of this job
foreach ($this->rules as $rule) { foreach ($this->rules as $rule) {
/** @var Rule $rule */
if ($job === $rule->getJob()) { if ($job === $rule->getJob()) {
$rule->disable(); $rule->disable();
} }
@ -562,13 +624,13 @@ class Solver
$this->makeAssertionRuleDecisions(); $this->makeAssertionRuleDecisions();
} }
/*------------------------------------------------------------------- /**
* enable/disable learnt rules * enable/disable learnt rules
* *
* we have enabled or disabled some of our rules. We now re-enable all * we have enabled or disabled some of our rules. We now re-enable all
* of our learnt rules except the ones that were learnt from rules that * of our learnt rules except the ones that were learnt from rules that
* are now disabled. * are now disabled.
*/ */
private function enableDisableLearnedRules() private function enableDisableLearnedRules()
{ {
foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) { foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
@ -591,22 +653,28 @@ class Solver
} }
} }
/**
* @param bool $disableRules
*/
private function runSat($disableRules = true) private function runSat($disableRules = true)
{ {
$this->propagateIndex = 0; $this->propagateIndex = 0;
// /* /*
// * here's the main loop: * here's the main loop:
// * 1) propagate new decisions (only needed once) * 1) propagate new decisions (only needed once)
// * 2) fulfill jobs * 2) fulfill jobs
// * 3) fulfill all unresolved rules * 3) fulfill all unresolved rules
// * 4) minimalize solution if we had choices * 4) minimalize solution if we had choices
// * if we encounter a problem, we rewind to a safe level and restart * if we encounter a problem, we rewind to a safe level and restart
// * with step 1 * with step 1
// */ */
$decisionQueue = array(); $decisionQueue = array();
$decisionSupplementQueue = array(); $decisionSupplementQueue = array();
/**
* @todo this makes $disableRules always false; determine the rationale and possibly remove dead code?
*/
$disableRules = array(); $disableRules = array();
$level = 1; $level = 1;

View File

@ -197,162 +197,202 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
{ {
return $this->aliasOf->getType(); return $this->aliasOf->getType();
} }
public function getTargetDir() public function getTargetDir()
{ {
return $this->aliasOf->getTargetDir(); return $this->aliasOf->getTargetDir();
} }
public function getExtra() public function getExtra()
{ {
return $this->aliasOf->getExtra(); return $this->aliasOf->getExtra();
} }
public function setInstallationSource($type) public function setInstallationSource($type)
{ {
$this->aliasOf->setInstallationSource($type); $this->aliasOf->setInstallationSource($type);
} }
public function getInstallationSource() public function getInstallationSource()
{ {
return $this->aliasOf->getInstallationSource(); return $this->aliasOf->getInstallationSource();
} }
public function getSourceType() public function getSourceType()
{ {
return $this->aliasOf->getSourceType(); return $this->aliasOf->getSourceType();
} }
public function getSourceUrl() public function getSourceUrl()
{ {
return $this->aliasOf->getSourceUrl(); return $this->aliasOf->getSourceUrl();
} }
public function getSourceUrls() public function getSourceUrls()
{ {
return $this->aliasOf->getSourceUrls(); return $this->aliasOf->getSourceUrls();
} }
public function getSourceReference() public function getSourceReference()
{ {
return $this->aliasOf->getSourceReference(); return $this->aliasOf->getSourceReference();
} }
public function setSourceReference($reference) public function setSourceReference($reference)
{ {
return $this->aliasOf->setSourceReference($reference); return $this->aliasOf->setSourceReference($reference);
} }
public function setSourceMirrors($mirrors) public function setSourceMirrors($mirrors)
{ {
return $this->aliasOf->setSourceMirrors($mirrors); return $this->aliasOf->setSourceMirrors($mirrors);
} }
public function getSourceMirrors() public function getSourceMirrors()
{ {
return $this->aliasOf->getSourceMirrors(); return $this->aliasOf->getSourceMirrors();
} }
public function getDistType() public function getDistType()
{ {
return $this->aliasOf->getDistType(); return $this->aliasOf->getDistType();
} }
public function getDistUrl() public function getDistUrl()
{ {
return $this->aliasOf->getDistUrl(); return $this->aliasOf->getDistUrl();
} }
public function getDistUrls() public function getDistUrls()
{ {
return $this->aliasOf->getDistUrls(); return $this->aliasOf->getDistUrls();
} }
public function getDistReference() public function getDistReference()
{ {
return $this->aliasOf->getDistReference(); return $this->aliasOf->getDistReference();
} }
public function setDistReference($reference) public function setDistReference($reference)
{ {
return $this->aliasOf->setDistReference($reference); return $this->aliasOf->setDistReference($reference);
} }
public function getDistSha1Checksum() public function getDistSha1Checksum()
{ {
return $this->aliasOf->getDistSha1Checksum(); return $this->aliasOf->getDistSha1Checksum();
} }
public function setTransportOptions(array $options) public function setTransportOptions(array $options)
{ {
return $this->aliasOf->setTransportOptions($options); return $this->aliasOf->setTransportOptions($options);
} }
public function getTransportOptions() public function getTransportOptions()
{ {
return $this->aliasOf->getTransportOptions(); return $this->aliasOf->getTransportOptions();
} }
public function setDistMirrors($mirrors) public function setDistMirrors($mirrors)
{ {
return $this->aliasOf->setDistMirrors($mirrors); return $this->aliasOf->setDistMirrors($mirrors);
} }
public function getDistMirrors() public function getDistMirrors()
{ {
return $this->aliasOf->getDistMirrors(); return $this->aliasOf->getDistMirrors();
} }
public function getScripts() public function getScripts()
{ {
return $this->aliasOf->getScripts(); return $this->aliasOf->getScripts();
} }
public function getLicense() public function getLicense()
{ {
return $this->aliasOf->getLicense(); return $this->aliasOf->getLicense();
} }
public function getAutoload() public function getAutoload()
{ {
return $this->aliasOf->getAutoload(); return $this->aliasOf->getAutoload();
} }
public function getDevAutoload() public function getDevAutoload()
{ {
return $this->aliasOf->getDevAutoload(); return $this->aliasOf->getDevAutoload();
} }
public function getIncludePaths() public function getIncludePaths()
{ {
return $this->aliasOf->getIncludePaths(); return $this->aliasOf->getIncludePaths();
} }
public function getRepositories() public function getRepositories()
{ {
return $this->aliasOf->getRepositories(); return $this->aliasOf->getRepositories();
} }
public function getReleaseDate() public function getReleaseDate()
{ {
return $this->aliasOf->getReleaseDate(); return $this->aliasOf->getReleaseDate();
} }
public function getBinaries() public function getBinaries()
{ {
return $this->aliasOf->getBinaries(); return $this->aliasOf->getBinaries();
} }
public function getKeywords() public function getKeywords()
{ {
return $this->aliasOf->getKeywords(); return $this->aliasOf->getKeywords();
} }
public function getDescription() public function getDescription()
{ {
return $this->aliasOf->getDescription(); return $this->aliasOf->getDescription();
} }
public function getHomepage() public function getHomepage()
{ {
return $this->aliasOf->getHomepage(); return $this->aliasOf->getHomepage();
} }
public function getSuggests() public function getSuggests()
{ {
return $this->aliasOf->getSuggests(); return $this->aliasOf->getSuggests();
} }
public function getAuthors() public function getAuthors()
{ {
return $this->aliasOf->getAuthors(); return $this->aliasOf->getAuthors();
} }
public function getSupport() public function getSupport()
{ {
return $this->aliasOf->getSupport(); return $this->aliasOf->getSupport();
} }
public function getNotificationUrl() public function getNotificationUrl()
{ {
return $this->aliasOf->getNotificationUrl(); return $this->aliasOf->getNotificationUrl();
} }
public function getArchiveExcludes() public function getArchiveExcludes()
{ {
return $this->aliasOf->getArchiveExcludes(); return $this->aliasOf->getArchiveExcludes();
} }
public function isAbandoned() public function isAbandoned()
{ {
return $this->aliasOf->isAbandoned(); return $this->aliasOf->isAbandoned();
} }
public function getReplacementPackage() public function getReplacementPackage()
{ {
return $this->aliasOf->getReplacementPackage(); return $this->aliasOf->getReplacementPackage();
} }
public function __toString() public function __toString()
{ {
return parent::__toString().' (alias of '.$this->aliasOf->getVersion().')'; return parent::__toString().' (alias of '.$this->aliasOf->getVersion().')';

View File

@ -113,7 +113,6 @@ class ProcessExecutor
* *
* @return string The escaped argument * @return string The escaped argument
*/ */
public static function escape($argument) public static function escape($argument)
{ {
return ProcessUtils::escapeArgument($argument); return ProcessUtils::escapeArgument($argument);

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Autoload; namespace Composer\Test\Autoload;
use Composer\Autoload\ClassLoader; use Composer\Autoload\ClassLoader;

View File

@ -1,14 +1,21 @@
<?php <?php
/* /*
* This file was copied from the Symfony package. * This file is part of Composer.
* *
* (c) Fabien Potencier <fabien@symfony.com> * (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
/*
* This file is copied from the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*/
namespace Composer\Test\Autoload; namespace Composer\Test\Autoload;
use Composer\Autoload\ClassMapGenerator; use Composer\Autoload\ClassMapGenerator;

View File

@ -9,6 +9,7 @@
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Test\DependencyResolver; namespace Composer\Test\DependencyResolver;
use Composer\Repository\ArrayRepository; use Composer\Repository\ArrayRepository;

View File

@ -1,14 +1,14 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *
* (c) Nils Adermann <naderman@naderman.de> * (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be> * Jordi Boggiano <j.boggiano@seld.be>
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Test\Util; namespace Composer\Test\Util;

View File

@ -1,4 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Util; namespace Composer\Test\Util;
use Composer\Config; use Composer\Config;