PhpMetrics
PhpMetrics copied to clipboard
Show error if yaml_parse function does not exists
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);
}