1
0
Fork 0

Remove further unnecessary checks for packages being arrays

pull/3447/head
Nils Adermann 2014-11-20 17:42:05 +01:00
parent 89bd9be295
commit dccb728e10
1 changed files with 8 additions and 27 deletions

View File

@ -217,9 +217,8 @@ class Pool
} }
if ($this->whitelist !== null && ( if ($this->whitelist !== null && (
(is_array($candidate) && isset($candidate['id']) && !isset($this->whitelist[$candidate['id']])) || (!($candidate instanceof AliasPackage) && !isset($this->whitelist[$candidate->getId()])) ||
(is_object($candidate) && !($candidate instanceof AliasPackage) && !isset($this->whitelist[$candidate->getId()])) || ($candidate instanceof AliasPackage && !isset($this->whitelist[$aliasOfCandidate->getId()]))
(is_object($candidate) && $candidate instanceof AliasPackage && !isset($this->whitelist[$aliasOfCandidate->getId()]))
)) { )) {
continue; continue;
} }
@ -313,19 +312,10 @@ class Pool
*/ */
private function match($candidate, $name, LinkConstraintInterface $constraint = null) private function match($candidate, $name, LinkConstraintInterface $constraint = null)
{ {
// handle array packages $candidateName = $candidate->getName();
if (is_array($candidate)) { $candidateVersion = $candidate->getVersion();
$candidateName = $candidate['name']; $isDev = $candidate->getStability() === 'dev';
$candidateVersion = $candidate['version']; $isAlias = $candidate instanceof AliasPackage;
$isDev = $candidate['stability'] === 'dev';
$isAlias = isset($candidate['alias_of']);
} else {
// handle object packages
$candidateName = $candidate->getName();
$candidateVersion = $candidate->getVersion();
$isDev = $candidate->getStability() === 'dev';
$isAlias = $candidate instanceof AliasPackage;
}
if (!$isDev && !$isAlias && isset($this->filterRequires[$name])) { if (!$isDev && !$isAlias && isset($this->filterRequires[$name])) {
$requireFilter = $this->filterRequires[$name]; $requireFilter = $this->filterRequires[$name];
@ -343,17 +333,8 @@ class Pool
return self::MATCH_NAME; return self::MATCH_NAME;
} }
if (is_array($candidate)) { $provides = $candidate->getProvides();
$provides = isset($candidate['provide']) $replaces = $candidate->getReplaces();
? $this->versionParser->parseLinks($candidateName, $candidateVersion, 'provides', $candidate['provide'])
: array();
$replaces = isset($candidate['replace'])
? $this->versionParser->parseLinks($candidateName, $candidateVersion, 'replaces', $candidate['replace'])
: array();
} else {
$provides = $candidate->getProvides();
$replaces = $candidate->getReplaces();
}
// aliases create multiple replaces/provides for one target so they can not use the shortcut below // aliases create multiple replaces/provides for one target so they can not use the shortcut below
if (isset($replaces[0]) || isset($provides[0])) { if (isset($replaces[0]) || isset($provides[0])) {