Fix 3 sonarqube bugs
continuous-integration/drone/push Build is passing Details

main
Hugo Thunnissen 2 years ago
parent f2df6c7a1b
commit f9d2feb9cb

@ -115,7 +115,7 @@ class AutoloadGenerator
public function setApcu(bool $apcu, ?string $apcuPrefix = null)
{
$this->apcu = $apcu;
$this->apcuPrefix = $apcuPrefix !== null ? $apcuPrefix : $apcuPrefix;
$this->apcuPrefix = $apcuPrefix;
}
/**

@ -243,15 +243,13 @@ class PhpFileCleaner
}
// skip the rest of the line
while ($this->index < $this->len) {
if ($this->index < $this->len) {
$this->skipToNewline();
// skip newlines
while ($this->index < $this->len && ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n")) {
$this->index += 1;
}
break;
}
}
}

@ -215,7 +215,7 @@ class Problem
if (PlatformRepository::isPlatformPackage($packageName)) {
// handle php/php-*/hhvm
if (0 === stripos($packageName, 'php') || $packageName === 'hhvm') {
$version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
$version = self::getPlatformPackageVersion($pool, $packageName);
$msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
@ -243,7 +243,7 @@ class Problem
$ext = substr($packageName, 4);
$msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ';
$version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
$version = self::getPlatformPackageVersion($pool, $packageName);
if (null === $version) {
if (extension_loaded($ext)) {
return array(
@ -427,39 +427,39 @@ class Problem
* @param string $version the effective runtime version of the platform package
* @return ?string a version string or null if it appears the package was artificially disabled
*/
private static function getPlatformPackageVersion(Pool $pool, string $packageName, string $version): ?string
private static function getPlatformPackageVersion(Pool $pool, string $packageName): ?string
{
$available = $pool->whatProvides($packageName);
if (count($available)) {
$selected = null;
foreach ($available as $pkg) {
if ($pkg->getRepository() instanceof PlatformRepository) {
$selected = $pkg;
break;
}
}
if ($selected === null) {
$selected = reset($available);
if (!count($available)) {
return null;
}
$selected = null;
foreach ($available as $pkg) {
if ($pkg->getRepository() instanceof PlatformRepository) {
$selected = $pkg;
break;
}
}
if ($selected === null) {
$selected = reset($available);
}
// must be a package providing/replacing and not a real platform package
if ($selected->getName() !== $packageName) {
/** @var Link $link */
foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
if ($link->getTarget() === $packageName) {
return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
}
// must be a package providing/replacing and not a real platform package
if ($selected->getName() !== $packageName) {
/** @var Link $link */
foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
if ($link->getTarget() === $packageName) {
return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
}
}
}
$version = $selected->getPrettyVersion();
$extra = $selected->getExtra();
if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
$version .= '; ' . str_replace('Package ', '', $selected->getDescription());
}
} else {
return null;
$version = $selected->getPrettyVersion();
$extra = $selected->getExtra();
if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
$version .= '; ' . str_replace('Package ', '', $selected->getDescription());
}
return $version;

Loading…
Cancel
Save