raspisms/tests/phpstan/run.php

50 lines
1.7 KiB
PHP
Raw Normal View History

2019-10-29 18:34:17 +01:00
#!/usr/bin/php
<?php
function help ()
{
2019-10-30 00:40:00 +01:00
echo 'Usage : ' . __FILE__ . ' <arg> [level 0-7]' . "\n" .
2019-10-29 18:34:17 +01:00
'Args :' . "\n" .
' - help : Show help message.' . "\n" .
' - analyse : Analyse code with phpstan.' . "\n";
exit(100);
}
$analyse_commands = [
2019-10-30 01:22:09 +01:00
'php ' . __DIR__ . '/phpstan.phar analyse --configuration="'. __DIR__ .'/config.neon" --autoload-file=' . __DIR__ . '/../../descartes/load.php ' . __DIR__ . '/../../controllers/',
'php ' . __DIR__ . '/phpstan.phar analyse --configuration="'. __DIR__ .'/config.neon" --autoload-file=' . __DIR__ . '/../../descartes/load.php ' . __DIR__ . '/../../models/',
2020-01-17 18:36:53 +01:00
'php ' . __DIR__ . '/phpstan.phar analyse --configuration="'. __DIR__ .'/config.neon" --autoload-file=' . __DIR__ . '/../../descartes/load.php ' . __DIR__ . '/../../adapters/',
'php ' . __DIR__ . '/phpstan.phar analyse --configuration="'. __DIR__ .'/config.neon" --autoload-file=' . __DIR__ . '/../../descartes/load.php ' . __DIR__ . '/../../daemons/',
2019-10-29 18:34:17 +01:00
];
if (count($argv) < 2 || $argv[1] === 'help')
{
help();
}
2019-10-30 01:22:09 +01:00
$level = $argv[2] ?? 0;
2019-10-29 18:34:17 +01:00
if ($argv[1] === 'analyse')
{
echo "######################" . "\n";
echo "# SHOW ERRORS TO FIX #" . "\n";
echo "######################" . "\n";
echo "\n";
foreach ($analyse_commands as $analyse_command)
{
2019-10-30 01:22:09 +01:00
$analyse_command .= ' --level=' . $level;
2019-10-30 00:40:00 +01:00
2019-10-29 18:34:17 +01:00
echo "Run : " . $analyse_command . " \n";
$return = shell_exec($analyse_command);
echo $return;
echo "\n\n";
}
exit(0);
}
echo "Invalid arg : " . $argv[1] . "\n";
help();