1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix copy/paste fail and other psalm/cs issues, reduce duplication of literals.

This commit is contained in:
AndrolGenhald 2021-12-09 17:13:52 -06:00
parent 5cd3b68ab3
commit c2b44ff073
2 changed files with 6 additions and 23 deletions

View File

@ -46,6 +46,7 @@ use UnexpectedValueException;
use XdgBaseDir\Xdg;
use stdClass;
use function array_key_exists;
use function array_map;
use function array_merge;
use function array_pad;
@ -999,33 +1000,19 @@ class Config
throw new UnexpectedValueException('Invalid composer.json at ' . $composer_json_path);
}
}
foreach ([
"decimal",
"dom",
"ds",
"geos",
"mongodb",
"mysqli",
"pdo",
"soap",
"xdebug",
] as $ext) {
foreach ($config->php_extensions as $ext => $_) {
$config->php_extensions[$ext] = isset($composer_json["require"]["ext-$ext"]);
}
if ($config->load_xdebug_stub !== null) {
$config->php_extensions[$ext] = $config->load_xdebug_stub;
$config->php_extensions["xdebug"] = $config->load_xdebug_stub;
}
if (isset($config_xml->enableExtensions) && isset($config_xml->enableExtensions->extension)) {
foreach ($config_xml->enableExtensions->extension as $extension) {
assert(isset($extension["name"]));
$extensionName = (string) $extension["name"];
assert(in_array(
$extensionName,
["decimal", "dom", "ds", "geos", "mongodb", "mysqli", "pdo", "soap", "xdebug"],
true
));
assert(array_key_exists($extensionName, $config->php_extensions));
$config->php_extensions[$extensionName] = true;
}
}
@ -1034,11 +1021,7 @@ class Config
foreach ($config_xml->disableExtensions->extension as $extension) {
assert(isset($extension["name"]));
$extensionName = (string) $extension["name"];
assert(in_array(
$extensionName,
["decimal", "dom", "ds", "geos", "mongodb", "mysqli", "pdo", "soap", "xdebug"],
true
));
assert(array_key_exists($extensionName, $config->php_extensions));
$config->php_extensions[$extensionName] = false;
}
}

View File

@ -3,6 +3,7 @@
namespace Psalm\Tests\Config;
use Psalm\Config;
use Psalm\Exception\ConfigException;
use Psalm\Internal\PluginManager\ConfigFile;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\TestCase;
@ -16,7 +17,6 @@ use function trim;
use function unlink;
use const PHP_EOL;
use Psalm\Exception\ConfigException;
/** @group PluginManager */
class ConfigFileTest extends TestCase