PluginDescription: use result of phpversion() to check if extension is loaded

technically phpstan should account for this with the extension_loaded() check, but it currently doesn't and it's not worth fighting with it when the fix is so simple anyway.
This commit is contained in:
Dylan K. Taylor 2020-04-15 12:50:53 +01:00
parent bbe428a874
commit cdda74ef93

View File

@ -28,7 +28,6 @@ use function array_map;
use function array_values; use function array_values;
use function constant; use function constant;
use function defined; use function defined;
use function extension_loaded;
use function is_array; use function is_array;
use function phpversion; use function phpversion;
use function preg_match; use function preg_match;
@ -230,11 +229,11 @@ class PluginDescription{
*/ */
public function checkRequiredExtensions(){ public function checkRequiredExtensions(){
foreach($this->extensions as $name => $versionConstrs){ foreach($this->extensions as $name => $versionConstrs){
if(!extension_loaded($name)){ $gotVersion = phpversion($name);
if($gotVersion === false){
throw new PluginException("Required extension $name not loaded"); throw new PluginException("Required extension $name not loaded");
} }
$gotVersion = phpversion($name);
foreach($versionConstrs as $constr){ // versionConstrs_loop foreach($versionConstrs as $constr){ // versionConstrs_loop
if($constr === "*"){ if($constr === "*"){
continue; continue;