PhpMetrics icon indicating copy to clipboard operation
PhpMetrics copied to clipboard

Show error if yaml_parse function does not exists

Open lutdev opened this issue 2 years ago • 0 comments

Feature request

Problem: I tried to run phpmetrcis with --config option:

php ./vendor/bin/phpmetrics --config=phpmetrics.yaml

And command finished without any error and not generated report.

The problem was because my PHP version (8.1) doesn't have yaml_parse function. Class Hal\Application\Config\File\ConfigFileReaderYaml::read() throw RuntimeException:

if (!function_exists('yaml_parse')) {
    throw new \RuntimeException('YAML parser not found. Please install the PECL extension "yaml".');
}

My proposition: Make changes in the src/Hal/Application/Application.php from this:

// config
$config = (new Parser())->parse($argv);

to this

// config
try{
    $config = (new Parser())->parse($argv);
} catch (\Throwable $exception) {
    $output->writeln($exception->getMessage());
    exit(0);
}

lutdev avatar Jul 01 '22 13:07 lutdev