raspisms/tests/php-cs-fixer/run.php

66 lines
1.6 KiB
PHP
Raw Normal View History

2019-10-29 16:52:49 +01:00
#!/usr/bin/php
<?php
2020-06-23 21:06:13 +02:00
function help()
2019-10-29 16:52:49 +01:00
{
echo 'Usage : ' . __FILE__ . ' <arg>' . "\n" .
'Args :' . "\n" .
' - help : Show help message.' . "\n" .
' - lint : Show coding standards to fix.' . "\n" .
2019-10-29 18:34:17 +01:00
' - fix : Fix coding standards.' . "\n";
2019-10-29 16:52:49 +01:00
exit(100);
}
$lint_commands = [
'php ' . __DIR__ . '/php-cs-fixer.phar -v --dry-run --config="' . __DIR__ . '/php_cs.config" fix',
2019-10-29 16:52:49 +01:00
];
2020-06-23 21:06:13 +02:00
2019-10-29 16:52:49 +01:00
$fix_commands = [
'php ' . __DIR__ . '/php-cs-fixer.phar --config="' . __DIR__ . '/php_cs.config" fix',
2019-10-29 16:52:49 +01:00
];
2020-06-23 21:06:13 +02:00
if (count($argv) < 2 || 'help' === $argv[1])
2019-10-29 16:52:49 +01:00
{
help();
}
2020-06-23 21:06:13 +02:00
if ('lint' === $argv[1])
2019-10-29 16:52:49 +01:00
{
2020-06-23 21:06:13 +02:00
echo '######################' . "\n";
echo '# SHOW ERRORS TO FIX #' . "\n";
echo '######################' . "\n";
2019-10-29 16:52:49 +01:00
echo "\n";
foreach ($lint_commands as $lint_command)
{
2020-06-23 21:06:13 +02:00
echo 'Run : ' . $lint_command . " \n";
2019-10-29 16:52:49 +01:00
$return = shell_exec($lint_command);
echo $return;
echo "\n\n";
}
2020-06-23 21:06:13 +02:00
2019-10-29 16:52:49 +01:00
exit(0);
}
2020-06-23 21:06:13 +02:00
if ('fix' === $argv[1])
2019-10-29 16:52:49 +01:00
{
2020-06-23 21:06:13 +02:00
echo '##############' . "\n";
echo '# FIX ERRORS #' . "\n";
echo '##############' . "\n";
2019-10-29 16:52:49 +01:00
echo "\n";
2020-06-23 21:06:13 +02:00
2019-10-29 16:52:49 +01:00
foreach ($fix_commands as $fix_command)
{
2020-06-23 21:06:13 +02:00
echo 'Run : ' . $fix_command . " \n";
2019-10-29 16:52:49 +01:00
$return = shell_exec($fix_command);
echo $return;
echo "\n\n";
}
2020-06-23 21:06:13 +02:00
2019-10-29 16:52:49 +01:00
exit(0);
}
2020-06-23 21:06:13 +02:00
echo 'Invalid arg : ' . $argv[1] . "\n";
2019-10-29 16:52:49 +01:00
help();