Skip to content

Commit

Permalink
Fix copy/paste fail and other psalm/cs issues, reduce duplication of …
Browse files Browse the repository at this point in the history
…literals.
  • Loading branch information
AndrolGenhald committed Dec 9, 2021
1 parent 9c11e63 commit 28a3efe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
27 changes: 5 additions & 22 deletions src/Psalm/Config.php
Expand Up @@ -41,6 +41,7 @@
use XdgBaseDir\Xdg;
use stdClass;

use function array_key_exists;
use function array_map;
use function array_merge;
use function array_pad;
Expand Down Expand Up @@ -971,33 +972,19 @@ private static function fromXmlAndPaths(
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;
}
}
Expand All @@ -1006,11 +993,7 @@ private static function fromXmlAndPaths(
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Config/ConfigFileTest.php
Expand Up @@ -2,6 +2,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;
Expand All @@ -15,7 +16,6 @@
use function unlink;

use const PHP_EOL;
use Psalm\Exception\ConfigException;

/** @group PluginManager */
class ConfigFileTest extends TestCase
Expand Down

0 comments on commit 28a3efe

Please sign in to comment.