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) public function setApcu(bool $apcu, ?string $apcuPrefix = null)
{ {
$this->apcu = $apcu; $this->apcu = $apcu;
$this->apcuPrefix = $apcuPrefix !== null ? $apcuPrefix : $apcuPrefix; $this->apcuPrefix = $apcuPrefix;
} }
/** /**

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

@ -215,7 +215,7 @@ class Problem
if (PlatformRepository::isPlatformPackage($packageName)) { if (PlatformRepository::isPlatformPackage($packageName)) {
// handle php/php-*/hhvm // handle php/php-*/hhvm
if (0 === stripos($packageName, 'php') || $packageName === '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 '; $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
@ -243,7 +243,7 @@ class Problem
$ext = substr($packageName, 4); $ext = substr($packageName, 4);
$msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but '; $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 (null === $version) {
if (extension_loaded($ext)) { if (extension_loaded($ext)) {
return array( return array(
@ -427,11 +427,14 @@ class Problem
* @param string $version the effective runtime version of the platform package * @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 * @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); $available = $pool->whatProvides($packageName);
if (count($available)) { if (!count($available)) {
return null;
}
$selected = null; $selected = null;
foreach ($available as $pkg) { foreach ($available as $pkg) {
if ($pkg->getRepository() instanceof PlatformRepository) { if ($pkg->getRepository() instanceof PlatformRepository) {
@ -458,9 +461,6 @@ class Problem
if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) { if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
$version .= '; ' . str_replace('Package ', '', $selected->getDescription()); $version .= '; ' . str_replace('Package ', '', $selected->getDescription());
} }
} else {
return null;
}
return $version; return $version;
} }

Loading…
Cancel
Save